This repository has been archived on 2023-08-29. You can view files and clone it, but cannot push or open issues/pull-requests.
yutent
/
anot.js
Archived
1
0
Fork 0
anot.js/src/14-buffer.js

27 lines
537 B
JavaScript
Raw Permalink Normal View History

2018-08-04 16:26:50 +08:00
//使用来自游戏界的双缓冲技术,减少对视图的冗余刷新
var Buffer = function() {
this.queue = []
}
Buffer.prototype = {
render: function(isAnimate) {
if (!this.locked) {
this.locked = isAnimate ? root.offsetHeight + 10 : 1
var me = this
Anot.nextTick(function() {
me.flush()
})
}
},
flush: function() {
for (var i = 0, sub; (sub = this.queue[i++]); ) {
sub.update && sub.update()
}
this.locked = 0
this.queue = []
}
}
var buffer = new Buffer()