Skip to content
Browse files

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
  • Loading branch information...
1 parent 8134fbf commit a7495f78878aa52e7e6bb41e4f1a21cebcf94ab3 @azakus azakus committed
Showing with 20 additions and 4 deletions.
  1. +20 −4 src/standard/gestures.html
View
24 src/standard/gestures.html
@@ -172,6 +172,17 @@
return;
}
var recognizers = Gestures.recognizers;
+ // reset recognizer state
+ for (var i = 0, r; i < recognizers.length; i++) {
+ r = recognizers[i];
+ if (gs[r.name] && !handled[r.name]) {
+ if (r.flow && r.flow.start.indexOf(ev.type) > -1) {
+ if (r.reset) {
+ r.reset();
+ }
+ }
+ }
+ }
// enforce gesture recognizer order
for (var i = 0, r; i < recognizers.length; i++) {
r = recognizers[i];
@@ -356,6 +367,10 @@
name: 'track',
touchAction: 'none',
deps: ['mousedown', 'touchstart', 'touchmove', 'touchend'],
+ flow: {
+ start: ['mousedown', 'touchstart'],
+ end: ['mouseup', 'touchend']
+ },
emits: ['track'],
info: {
@@ -373,7 +388,7 @@
prevent: false
},
- clearInfo: function() {
+ reset: function() {
this.info.state = 'start';
this.info.started = false;
this.info.moves = [];
@@ -412,7 +427,6 @@
Gestures.prevent('tap');
movefn(e);
}
- self.clearInfo();
// remove the temporary listeners
document.removeEventListener('mousemove', movefn);
document.removeEventListener('mouseup', upfn);
@@ -454,7 +468,6 @@
this.info.addMove({x: ct.clientX, y: ct.clientY});
this.fire(t, ct);
}
- this.clearInfo();
},
fire: function(target, touch) {
@@ -487,6 +500,10 @@
Gestures.register({
name: 'tap',
deps: ['mousedown', 'click', 'touchstart', 'touchend'],
+ flow: {
+ start: ['mousedown', 'touchstart'],
+ end: ['click', 'touchend']
+ },
emits: ['tap'],
info: {
x: NaN,
@@ -532,7 +549,6 @@
});
}
}
- this.reset();
}
});

0 comments on commit a7495f7

Please sign in to comment.
Something went wrong with that request. Please try again.