Skip to content

Instantly share code, notes, and snippets.

@paulirish
Created February 23, 2011 02:35
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save paulirish/839879 to your computer and use it in GitHub Desktop.
Save paulirish/839879 to your computer and use it in GitHub Desktop.
requestAnimFrame() shim.
// see http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// shim layer with setTimeout fallback
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback, element){
window.setTimeout(function(){
callback(+new Date);
}, 1000 / 60);
};
})();
@paulirish
Copy link
Author

I've since updated this gist to remove the timeundefined issue as it was specific to Chrome 10 which is now dead and gone. hooray for software updates!

@paulirish
Copy link
Author

Don't use this

use this:

https://gist.github.com/1579671

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment