1
0
Fork 0
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:
Simo Kinnunen 2014-04-03 17:13:17 +09:00
parent ceeda2b990
commit c33f0eab09
6 changed files with 68 additions and 22 deletions

26
lib/wire/seqqueue.js Normal file
View 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