Created
May 16, 2013 10:27
-
-
Save drzhbe/5590808 to your computer and use it in GitHub Desktop.
This file contains 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
// shim layer with setTimeout fallback | |
window.requestAnimFrame = (function(){ | |
return window.requestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
function( callback ){ | |
window.setTimeout(callback, 1000 / 60); | |
}; | |
})(); | |
// usage: | |
// instead of setInterval(render, 16) .... | |
(function animloop(){ | |
requestAnimFrame(animloop); | |
render(); | |
})(); | |
// place the rAF *before* the render() to assure as close to | |
// 60fps with the setTimeout fallback. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment