Skip to content

Instantly share code, notes, and snippets.

@r17x
Created March 3, 2019 13:19
Show Gist options
  • Select an option

  • Save r17x/b0a4945d9dcc52e845aa2f57ff4333b3 to your computer and use it in GitHub Desktop.

Select an option

Save r17x/b0a4945d9dcc52e845aa2f57ff4333b3 to your computer and use it in GitHub Desktop.
// shim layer for requestAnimationFrame with setTimeout fallback
// from http://paulirish.com/2011/requestanimationframe-for-smart-animating/
var requestAnimFrame = (function(){
  return window.requestAnimationFrame       || 
         window.webkitRequestAnimationFrame || 
         window.mozRequestAnimationFrame    || 
         window.oRequestAnimationFrame      || 
         window.msRequestAnimationFrame     || 
         function( callback ){
           window.setTimeout(callback, 1000 / 60);
         };
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment