-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow very small twodrag and pinch gestures #1916
base: master
Are you sure you want to change the base?
Conversation
Before this commit, we strictly required the user to make a ~50 pixel move in order to get these two gestures. We can get a more precise experience if we allow very small gestures as well. This can be achieved by making better use of our "_twoTouchTimeout". Our two touch timeout handling was written to handle this well anyway. We can distinguish between drag and pinch using the angle.
This also makes things easier for things like #1835 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some more design work is needed, as this seems to cause some gestures to become very unreliable. The threshold was pretty fundamental in the existing design to separate things.
@@ -580,7 +580,7 @@ describe('Gesture handler', function () { | |||
touchStart(1, 50.0, 40.0); | |||
touchStart(2, 60.0, 40.0); | |||
touchMove(1, 80.0, 40.0); | |||
touchMove(2, 110.0, 40.0); | |||
touchMove(2, 90.0, 40.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely clear on why these unit tests needed to be changed?
if (deltaMove >= GH_MOVE_THRESHOLD) { | ||
this._state &= ~(GH_ONETAP | GH_TWOTAP | GH_THREETAP | GH_LONGPRESS); | ||
this._stopLongpressTimeout(); | ||
} | ||
|
||
if (this._tracked.length !== 1) { | ||
this._state &= ~(GH_DRAG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have already been excluded in the touchstart handler. Perhaps best to remove this redundancy to make things easier to read and understand.
// Ignore moves smaller than the minimum threshold | ||
if (Math.hypot(deltaX, deltaY) < GH_MOVE_THRESHOLD) { | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks two finger gestures if the first finger moves slightly before the second finger makes its initial touch. Which I'd suspect is very likely, given how sensitive touch devices are.
@@ -234,7 +234,8 @@ export default class GestureHandler { | |||
} | |||
} else if (!this._isTwoTouchTimeoutRunning()) { | |||
// We can't determine the gesture right now, let's | |||
// wait and see if more events are on their way | |||
// wait and see if more events are on their way. | |||
// If not, we'll have to decide which gesture it is. | |||
this._startTwoTouchTimeout(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks other two finger gestures as the two touch timeout blindly assumes that only a pinch or drag is left to choose from. It might need to be fixed so it also just excludes things, leaving it still uncertain for any other gestures that have yet to be ruled out.
I'm not sure if this timeout was ever really used, or at least very little, given the existing large movement threshold. We might need to reexamine it in detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lack of distance threshold also means that the timeout handler has much more noisy data to deal with when trying to identify a pinch from a drag. So it might be much less robust there as well.
Before this commit, we strictly required the user to make a ~50 pixel move in order to get these two gestures. We can get a more precise experience if we allow very small gestures as well. This can be achieved by making better use of our "_twoTouchTimeout".
Our two touch timeout handling was written to handle this well anyway. We can distinguish between drag and pinch using the angle.
This is a prerequisite for browser-side gestures like in #1809 to work well.