Skip to content

Commit a7495f7

Browse files
committed
Move recognizer reset into start of event flow
Add "event flow" metadata to each recognizer, list of start/end events Normalize state reset function names flow.start is an array, not an object Make sure to reset state in a seperate loop Otherwise prevent on 'down' breaks
1 parent 8134fbf commit a7495f7

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

‎src/standard/gestures.html‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,17 @@
172172
return;
173173
}
174174
var recognizers = Gestures.recognizers;
175+
// reset recognizer state
176+
for (var i = 0, r; i < recognizers.length; i++) {
177+
r = recognizers[i];
178+
if (gs[r.name] && !handled[r.name]) {
179+
if (r.flow && r.flow.start.indexOf(ev.type) > -1) {
180+
if (r.reset) {
181+
r.reset();
182+
}
183+
}
184+
}
185+
}
175186
// enforce gesture recognizer order
176187
for (var i = 0, r; i < recognizers.length; i++) {
177188
r = recognizers[i];
@@ -356,6 +367,10 @@
356367
name: 'track',
357368
touchAction: 'none',
358369
deps: ['mousedown', 'touchstart', 'touchmove', 'touchend'],
370+
flow: {
371+
start: ['mousedown', 'touchstart'],
372+
end: ['mouseup', 'touchend']
373+
},
359374
emits: ['track'],
360375

361376
info: {
@@ -373,7 +388,7 @@
373388
prevent: false
374389
},
375390

376-
clearInfo: function() {
391+
reset: function() {
377392
this.info.state = 'start';
378393
this.info.started = false;
379394
this.info.moves = [];
@@ -412,7 +427,6 @@
412427
Gestures.prevent('tap');
413428
movefn(e);
414429
}
415-
self.clearInfo();
416430
// remove the temporary listeners
417431
document.removeEventListener('mousemove', movefn);
418432
document.removeEventListener('mouseup', upfn);
@@ -454,7 +468,6 @@
454468
this.info.addMove({x: ct.clientX, y: ct.clientY});
455469
this.fire(t, ct);
456470
}
457-
this.clearInfo();
458471
},
459472

460473
fire: function(target, touch) {
@@ -487,6 +500,10 @@
487500
Gestures.register({
488501
name: 'tap',
489502
deps: ['mousedown', 'click', 'touchstart', 'touchend'],
503+
flow: {
504+
start: ['mousedown', 'touchstart'],
505+
end: ['click', 'touchend']
506+
},
490507
emits: ['tap'],
491508
info: {
492509
x: NaN,
@@ -532,7 +549,6 @@
532549
});
533550
}
534551
}
535-
this.reset();
536552
}
537553
});
538554

0 commit comments

Comments
 (0)