mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Make sure touch events arrive in correct order.
This commit is contained in:
parent
ceeda2b990
commit
c33f0eab09
6 changed files with 68 additions and 22 deletions
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
|
Loading…
Add table
Add a link
Reference in a new issue