Keeping compatibility

suggest change

Unprefixed requestAnimationFrame is standard in current browsers. Older WebKit and Gecko builds exposed webkitRequestAnimationFrame and mozRequestAnimationFrame. This fallback covers those names:

window.requestAnimationFrame = (function(){
    return window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        function(callback){
            window.setTimeout(callback, 1000 / 60);
        };
})();

setTimeout does return an id, but cancelAnimationFrame does not clear a timeout, and the callback does not receive the timestamp that requestAnimationFrame passes. A fuller polyfill is at https://gist.github.com/paulirish/1579671. That gist was not rechecked for this edition.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents