use requestAnimationFrame
This commit is contained in:
parent
ca26a82ef9
commit
6dddfe8edd
2 changed files with 17 additions and 10 deletions
|
|
@ -298,11 +298,18 @@ if (window.postMessage && !useragent.isOldIE) {
|
|||
win.postMessage(messageName, "*");
|
||||
};
|
||||
}
|
||||
else {
|
||||
exports.nextTick = function(callback, win) {
|
||||
win = win || window;
|
||||
window.setTimeout(callback, 0);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
exports.nextFrame = window.requestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame;
|
||||
|
||||
if (exports.nextFrame)
|
||||
exports.nextFrame = exports.nextFrame.bind(window);
|
||||
else
|
||||
exports.nextFrame = function(callback) {
|
||||
setTimeout(callback, 17);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ var RenderLoop = function(onRender, win) {
|
|||
if (!this.pending) {
|
||||
this.pending = true;
|
||||
var _self = this;
|
||||
event.nextTick(function() {
|
||||
event.nextFrame(function() {
|
||||
_self.pending = false;
|
||||
var changes;
|
||||
while (changes = _self.changes) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue