Skip to content

Instantly share code, notes, and snippets.

@gonzaloruizdevilla
Created March 23, 2012 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonzaloruizdevilla/2174427 to your computer and use it in GitHub Desktop.
Save gonzaloruizdevilla/2174427 to your computer and use it in GitHub Desktop.
requestAnimationFrame con polyfill
// shim con fallback a setTimeout
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
// uso:
// en lugar de setInterval(render, 16) ....
(function loopAnimacion(){
requestAnimFrame(loopAnimacion);
hazLosCalculos();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment