标签:
1 // handle multiple browsers for requestAnimationFrame() 2 window.requestAFrame = (function () { 3 return window.requestAnimationFrame || 4 window.webkitRequestAnimationFrame || 5 window.mozRequestAnimationFrame || 6 window.oRequestAnimationFrame || 7 // if all else fails, use setTimeout 8 function (callback) { 9 return window.setTimeout(callback, 1000 / 60); // shoot for 60 fps 10 }; 11 })(); 12 13 // handle multiple browsers for cancelAnimationFrame() 14 window.cancelAFrame = (function () { 15 return window.cancelAnimationFrame || 16 window.webkitCancelAnimationFrame || 17 window.mozCancelAnimationFrame || 18 window.oCancelAnimationFrame || 19 function (id) { 20 window.clearTimeout(id); 21 }; 22 })();
http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
实现Animating使用requestAnimationFrame,尽量不用setInterval,setTimeout
标签:
原文地址:http://www.cnblogs.com/yxzblue/p/4273520.html