don't swallow redraws
This commit is contained in:
parent
88b91b1073
commit
9afefe0fd7
2 changed files with 26 additions and 2 deletions
|
|
@ -74,11 +74,35 @@ o.spec("throttle", function() {
|
|||
}, FRAME_BUDGET)
|
||||
})
|
||||
|
||||
o("it supports forcing a synchronous redraw", function() {
|
||||
o("it supports forcing a synchronous redraw", function(done) {
|
||||
throttled()
|
||||
throttled()
|
||||
throttled(true)
|
||||
|
||||
o(spy.callCount).equals(2)
|
||||
|
||||
setTimeout(function() {
|
||||
o(spy.callCount).equals(3)
|
||||
|
||||
done()
|
||||
}, FRAME_BUDGET)
|
||||
})
|
||||
|
||||
o("it doesn't swallow redraws", function(done, timeout) {
|
||||
timeout(60)
|
||||
|
||||
throttled()
|
||||
|
||||
setTimeout(function() {
|
||||
throttled()
|
||||
setTimeout(function() {
|
||||
throttled()
|
||||
setTimeout(function() {
|
||||
o(spy.callCount).equals(3)
|
||||
|
||||
done()
|
||||
}, FRAME_BUDGET)
|
||||
}, 0)
|
||||
}, 0)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module.exports = function(callback) {
|
|||
}
|
||||
else if (pending === null) {
|
||||
pending = timeout(function() {
|
||||
pending = 0
|
||||
pending = null
|
||||
callback()
|
||||
last = new Date().getTime()
|
||||
}, time - (now - last))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue