update 0.9.0 goodies

This commit is contained in:
Rupert Hausberger 2017-08-15 00:49:19 +02:00
commit e401b93e22
11 changed files with 514 additions and 93 deletions

24
sae/prototypes.js vendored
View file

@ -76,3 +76,27 @@ if (!performance.now) {
return Date.now() - this.timing.navigationStart;
};
}
/*-----------------------------------------------------------------------*/
/* AnimationFrame */
(function() {
var lastTime = 0;
if (!window.requestAnimationFrame) {
console.warn("This browser does not support 'window.requestAnimationFrame'. Falling back to 'setTimeout'...");
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}
if (!window.cancelAnimationFrame) {
console.warn("This browser does not support 'window.cancelAnimationFrame'. Falling back to 'clearTimeout'...");
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}
}());