Add drag threshold to improve click experience #4426
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It has been a problem for a long time which I've also seen in many user recordings that a drag starts when any distance is travelled by the mouse after mouse down. This means that for a click to register, the mouse has to stay perfectly still between mouse down and up. That's hard to do with precision input devices like my Macbook's trackpad. When implementing this code, I frequently see difference values like 0.1 or 0.2 pixels, you don't even see the cursor move (as it's snapped to the pixel grid) but no click is happening.
This PR adds a small threshold in pixels that the mouse has to travel before a drag starts. Until then, if the mouse goes up, a click will be registered. For me this is immediately noticeable in usability. The threshold value 2 that I chose is kind of arbitrary but seemed to work well enough, at some point higher values feel weird as dragging a slider, for example, seems to start too late.