Skip to content

Instantly share code, notes, and snippets.

@sapphiriq
Forked from paulirish/gist:839879
Created October 11, 2012 08:37
Show Gist options
  • Select an option

  • Save sapphiriq/3871020 to your computer and use it in GitHub Desktop.

Select an option

Save sapphiriq/3871020 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);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment