Archivi tag: firefox nightly

Request Animation Frame polyfill for Firefox nightly

Recently I tried a script uses Request Animation Frame with jsTimers-rAF-hack on firefox nightly and I saw  it doesn’t work. I debugged and I saw requestAnimationFrame into window object, but cancelAnimationFrame doesn’t, so the find browser methods doesn’t work fine.

So this is Erik Möller polyfill find browser methods fixed

var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length 
     && (window.requestAnimationFrame===undefined || 
       window.cancelAnimationFrame === undefined);
 ++x) {
     if(window.requestAnimationFrame === undefined)
         window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
     if(window.cancelAnimationFrame === undefined)
         window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
}

if (!window.requestAnimationFrame)
    //do some thing