Created
February 23, 2011 02:35
-
-
Save paulirish/839879 to your computer and use it in GitHub Desktop.
requestAnimFrame() shim.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!