mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-17 23:53:25 +02:00
Make sure touch events arrive in correct order.
This commit is contained in:
26
lib/wire/seqqueue.js
Normal file
26
lib/wire/seqqueue.js
Normal file
@@ -0,0 +1,26 @@
|
||||
function SeqQueue() {
|
||||
this.queue = []
|
||||
this.seq = 0
|
||||
}
|
||||
|
||||
SeqQueue.prototype.push = function(seq, handler) {
|
||||
this.queue[seq] = handler
|
||||
this.maybeDequeue()
|
||||
}
|
||||
|
||||
SeqQueue.prototype.done = function(seq, handler) {
|
||||
this.queue[seq] = handler
|
||||
this.maybeDequeue()
|
||||
}
|
||||
|
||||
SeqQueue.prototype.maybeDequeue = function() {
|
||||
var handler
|
||||
|
||||
while ((handler = this.queue[this.seq])) {
|
||||
this.queue[this.seq] = void 0
|
||||
handler()
|
||||
this.seq += 1
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SeqQueue
|
||||
Reference in New Issue
Block a user