Skip to content
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

Add drag threshold to improve click experience #4426

Merged
merged 6 commits into from
Oct 1, 2024

Conversation

jkrumbiegel
Copy link
Member

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.

@MakieBot
Copy link
Collaborator

MakieBot commented Sep 30, 2024

Compile Times benchmark

Note, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running:

using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(fig)
using create display create display
GLMakie 4.50s (4.44, 4.57) 0.04+- 110.84ms (105.77, 120.70) 6.12+- 485.39ms (472.96, 504.51) 11.31+- 9.43ms (9.01, 9.68) 0.27+- 26.43ms (26.05, 26.89) 0.27+-
master 4.53s (4.44, 4.66) 0.10+- 111.30ms (105.63, 126.97) 7.27+- 485.17ms (471.15, 514.94) 16.63+- 9.46ms (8.75, 9.85) 0.34+- 26.29ms (26.02, 26.64) 0.25+-
evaluation 1.01x invariant, -0.03s (-0.40d, 0.47p, 0.07std) 1.00x invariant, -0.45ms (-0.07d, 0.90p, 6.70std) 1.00x invariant, 0.22ms (0.02d, 0.98p, 13.97std) 1.00x invariant, -0.03ms (-0.10d, 0.86p, 0.31std) 0.99x invariant, 0.15ms (0.56d, 0.31p, 0.26std)
CairoMakie 4.24s (4.18, 4.34) 0.05+- 109.58ms (107.35, 111.62) 1.57+- 172.71ms (168.58, 176.39) 2.45+- 9.81ms (9.72, 9.94) 0.08+- 1.17ms (1.13, 1.19) 0.02+-
master 4.22s (4.19, 4.25) 0.02+- 112.98ms (107.84, 117.80) 3.34+- 175.95ms (169.35, 185.93) 6.28+- 9.82ms (9.67, 10.05) 0.16+- 1.18ms (1.14, 1.21) 0.03+-
evaluation 1.00x invariant, 0.01s (0.35d, 0.53p, 0.04std) 1.03x faster ✓, -3.4ms (-1.30d, 0.04p, 2.46std) 1.02x invariant, -3.24ms (-0.68d, 0.24p, 4.36std) 1.00x invariant, -0.01ms (-0.09d, 0.87p, 0.12std) 1.01x invariant, -0.01ms (-0.28d, 0.61p, 0.03std)
WGLMakie 4.72s (4.65, 4.78) 0.05+- 108.17ms (105.63, 112.83) 2.35+- 9.47s (9.25, 9.68) 0.13+- 11.71ms (11.35, 12.41) 0.35+- 124.94ms (116.28, 162.97) 16.83+-
master 4.75s (4.70, 4.80) 0.03+- 109.68ms (107.16, 113.78) 2.11+- 9.47s (9.32, 9.69) 0.12+- 11.61ms (11.51, 11.81) 0.11+- 119.37ms (114.83, 121.18) 2.22+-
evaluation 1.01x invariant, -0.03s (-0.61d, 0.28p, 0.04std) 1.01x invariant, -1.51ms (-0.67d, 0.23p, 2.23std) 1.00x invariant, -0.0s (-0.01d, 0.98p, 0.13std) 0.99x invariant, 0.11ms (0.42d, 0.46p, 0.23std) 0.96x invariant, 5.56ms (0.46d, 0.42p, 9.52std)

@jkrumbiegel jkrumbiegel merged commit f1c1918 into master Oct 1, 2024
18 checks passed
@jkrumbiegel jkrumbiegel deleted the jk/click-error-tolerance branch October 1, 2024 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

3 participants