(function() { var i, lastTime, len, vendor, vendors; lastTime = 0; vendors = ['webkit', 'moz']; for (i = 0, len = vendors.length; i < len; i++) { vendor = vendors[i]; if (!(!window.requestAnimationFrame)) { continue; } window.requestAnimationFrame = window[vendor + "RequestAnimationFrame"]; window.cancelAnimationFrame = window[vendor + "CancelAnimationFrame"] || window[vendor + "CancelRequestAnimationFrame"]; } if (!window.requestAnimationFrame) { window.requestAnimationFrame = function(callback, element) { var currTime, id, timeToCall; currTime = Date.now(); timeToCall = Math.max(0, 16 - (currTime - lastTime)); id = setTimeout(function() { return callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; }; } if (!window.cancelAnimationFrame) { window.cancelAnimationFrame = window.clearTimeout; } }).call(this);