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 {
} else {
assert(disposition == GestureDisposition.accepted);
if (state.isOpen) {
if (state.eagerWinner == null)
state.eagerWinner = member;
state.eagerWinner ??= member;
} else {
_resolveInFavorOf(key, state, member);
}
......
......@@ -112,7 +112,7 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
// TODO(abarth): Maybe factor the slop handling out into a separate class?
if (event.type == 'pointermove' && _getDistance(event) > kTouchSlop) {
resolve(GestureDisposition.rejected);
stopTrackingPointer(event.pointer);
stopTrackingPointer(primaryPointer);
} else {
handlePrimaryPointer(event);
}
......
......@@ -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() {
_checkDown();
}
......
......@@ -161,19 +161,28 @@ void main() {
tap.onTap = () {
tapRecognized = true;
};
bool tapCanceled = false;
tap.onTapCancel = () {
tapCanceled = true;
};
tap.addPointer(down3);
GestureArena.instance.close(3);
expect(tapRecognized, isFalse);
expect(tapCanceled, isFalse);
router.route(down3);
expect(tapRecognized, isFalse);
expect(tapCanceled, isFalse);
router.route(move3);
expect(tapRecognized, isFalse);
expect(tapCanceled, isTrue);
router.route(up3);
expect(tapRecognized, isFalse);
expect(tapCanceled, isTrue);
GestureArena.instance.sweep(3);
expect(tapRecognized, isFalse);
expect(tapCanceled, isTrue);
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