if (!(Date.now && Date.prototype.getTime)) { Date.now = function now(){ return new Date().getTime(); } ; } if (!(global.performance && global.performance.now)) { var startTime = Date.now(); if (!global.performance) { global.performance = { } ; } global.performance.now = function (){ return Date.now() - startTime; } ; } var lastTime = Date.now(); var vendors = ['ms', 'moz', 'webkit', 'o'] ; for (var x = 0; x < _AN_Read_length('length', vendors) && !global.requestAnimationFrame; ++x){ global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || global[vendors[x] + 'CancelRequestAnimationFrame']; } if (!global.requestAnimationFrame) { global.requestAnimationFrame = function (callback){ if (typeof callback !== 'function') { throw new TypeError(callback + 'is not a function') } var currentTime = Date.now(), delay = 16 + lastTime - currentTime; if (delay < 0) { delay = 0; } lastTime = currentTime; return _AN_Call_settimeout('setTimeout', window, function (){ lastTime = Date.now(); callback(performance.now()); } , delay); } ; } if (!global.cancelAnimationFrame) { global.cancelAnimationFrame = function (id){ clearTimeout(id); } ; }