Commit fc5832dc authored by Ian Hickson's avatar Ian Hickson

Merge pull request #355 from Hixie/tap-bugs

Fix tapcancel on slop.
parents 16471d92 c40cb176
...@@ -146,8 +146,7 @@ class GestureArena { ...@@ -146,8 +146,7 @@ class GestureArena {
} else { } else {
assert(disposition == GestureDisposition.accepted); assert(disposition == GestureDisposition.accepted);
if (state.isOpen) { if (state.isOpen) {
if (state.eagerWinner == null) state.eagerWinner ??= member;
state.eagerWinner = member;
} else { } else {
_resolveInFavorOf(key, state, member); _resolveInFavorOf(key, state, member);
} }
...@@ -166,4 +165,4 @@ class GestureArena { ...@@ -166,4 +165,4 @@ class GestureArena {
} }
member.acceptGesture(key); member.acceptGesture(key);
} }
} }
\ No newline at end of file
...@@ -112,7 +112,7 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni ...@@ -112,7 +112,7 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
// TODO(abarth): Maybe factor the slop handling out into a separate class? // TODO(abarth): Maybe factor the slop handling out into a separate class?
if (event.type == 'pointermove' && _getDistance(event) > kTouchSlop) { if (event.type == 'pointermove' && _getDistance(event) > kTouchSlop) {
resolve(GestureDisposition.rejected); resolve(GestureDisposition.rejected);
stopTrackingPointer(event.pointer); stopTrackingPointer(primaryPointer);
} else { } else {
handlePrimaryPointer(event); handlePrimaryPointer(event);
} }
......
...@@ -43,6 +43,15 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer { ...@@ -43,6 +43,15 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
} }
} }
void resolve(GestureDisposition disposition) {
if (_wonArena && disposition == GestureDisposition.rejected) {
if (onTapCancel != null)
onTapCancel();
_reset();
}
super.resolve(disposition);
}
void didExceedDeadline() { void didExceedDeadline() {
_checkDown(); _checkDown();
} }
......
...@@ -161,19 +161,28 @@ void main() { ...@@ -161,19 +161,28 @@ void main() {
tap.onTap = () { tap.onTap = () {
tapRecognized = true; tapRecognized = true;
}; };
bool tapCanceled = false;
tap.onTapCancel = () {
tapCanceled = true;
};
tap.addPointer(down3); tap.addPointer(down3);
GestureArena.instance.close(3); GestureArena.instance.close(3);
expect(tapRecognized, isFalse); expect(tapRecognized, isFalse);
expect(tapCanceled, isFalse);
router.route(down3); router.route(down3);
expect(tapRecognized, isFalse); expect(tapRecognized, isFalse);
expect(tapCanceled, isFalse);
router.route(move3); router.route(move3);
expect(tapRecognized, isFalse); expect(tapRecognized, isFalse);
expect(tapCanceled, isTrue);
router.route(up3); router.route(up3);
expect(tapRecognized, isFalse); expect(tapRecognized, isFalse);
expect(tapCanceled, isTrue);
GestureArena.instance.sweep(3); GestureArena.instance.sweep(3);
expect(tapRecognized, isFalse); expect(tapRecognized, isFalse);
expect(tapCanceled, isTrue);
tap.dispose(); tap.dispose();
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment