requestAnimationFrame cannot be used in Webkit

since it is not fired when the window is not
focused/visible.
This commit is contained in:
Fabian Jakobs 2011-10-18 16:46:54 +02:00
commit 9ab8d986cd

View file

@ -61,20 +61,11 @@ var RenderLoop = function(onRender, window) {
var changes = _self.changes; var changes = _self.changes;
_self.changes = 0; _self.changes = 0;
_self.onRender(changes); _self.onRender(changes);
}) });
} }
}; };
this.setTimeoutZero = window.requestAnimationFrame || if (window.postMessage) {
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame;
if (this.setTimeoutZero) {
this.setTimeoutZero = this.setTimeoutZero;
} else if (window.postMessage) {
this.setTimeoutZero = (function(messageName, attached, listener) { this.setTimeoutZero = (function(messageName, attached, listener) {
return function setTimeoutZero(callback) { return function setTimeoutZero(callback) {
// Set up listener if not listening already. // Set up listener if not listening already.
@ -92,12 +83,11 @@ var RenderLoop = function(onRender, window) {
this.postMessage(messageName, "*"); this.postMessage(messageName, "*");
}; };
})("zero-timeout-message", false, null); })("zero-timeout-message", false, null);
}
} else { else {
this.setTimeoutZero = function(callback) { this.setTimeoutZero = function(callback) {
this.setTimeout(callback, 0); this.setTimeout(callback, 0);
} };
} }
}).call(RenderLoop.prototype); }).call(RenderLoop.prototype);