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

Bug 1392361 - Fix zooming sensitivity on macOS #12203

Merged
merged 1 commit into from
Aug 16, 2020

Conversation

staktrace
Copy link
Contributor

The original code would get a long sequence of miniscule "tick" values while
pinch-zooming, and each tick value would cause a 1.1x zoom. So even the smallest
pinch gesture on a trackpad would cause high amounts of zoom. This patch
accumulates the wheel deltas until they reach an integer threshold (with a
tweak of the scaling factor to make it feel more natural) at which point it
triggers the zoom based on the integer component of the accumulated delta. The
fractional part is retained in the accumulator.

Fixes #8802

@staktrace
Copy link
Contributor Author

I tested this on Firefox Nightly with the following inputs:

  • macOS with trackpad pinch, with apz.allow_zooming=true,false
  • macOS with ctrl+two-finger-scroll, with apz.allow_zooming=true,false
  • Windows trackpad two finger pinch (uses direct manipulation), with apz.allow_zooming=true
  • Windows trackpad two finger pinch with apz.allow_zooming=false (does nothing)
  • Windows trackpad ctrl+scroll, with apz.allow_zooming=true,false

Also tested on Chrome on macOS with trackpad pinch and ctrl+scroll.

In all cases the behaviour seemed reasonable.

@staktrace
Copy link
Contributor Author

There's a deployed version at https://mozilla.staktrace.com/tmp/fixzoom/generic/web/viewer.html if you want to try yourself.

@Snuffleupagus
Copy link
Collaborator

Unfortunately this performs significantly worse when using a mouse with a scrollwheel, in my case a Logitech G403, on Windows.

I've testing using Ctrl+scrollwheel up, one increment at a time, and get the following sequence of zoom values:

  • With the PDF.js master branch: auto (= 125%) -> 140% -> 160% -> 180% -> 200% -> ...
    This is basically equivalent to the values I get when zooming using only the keyboard, i.e. with Ctrl++.
  • With your demo: auto (= 125%) -> 180% -> 250% -> 350% -> 480% -> ...
    This unfortunately renders mousewheel zooming more-or-less unusable as-is.

@staktrace
Copy link
Contributor Author

Indeed, I can reproduce. I should have tried that before submitting the patch, sorry. Fix coming.

@staktrace
Copy link
Contributor Author

Hm so actually this is because Windows defaults to three lines per mousewheel roll on line-based devices. On macOS it seems to default to 1. I guess for line-based devices we should consider one tick per event or something, since line-based devices are generally wheels with clicky wheels and one click would nicely correspond to one zoom step.

The original code would get a long sequence of miniscule "tick" values while
pinch-zooming, and each tick value would cause a 1.1x zoom. So even the smallest
pinch gesture on a trackpad would cause high amounts of zoom. This patch
accumulates the wheel deltas until they reach an integer threshold (with a
tweak of the scaling factor to make it feel more natural) at which point it
triggers the zoom based on the integer component of the accumulated delta. The
fractional part is retained in the accumulator.
@staktrace
Copy link
Contributor Author

Patch updated. New version is deployed at https://mozilla.staktrace.com/tmp/fixzoom2/generic/web/viewer.html - please give it a whirl and let me know how it feels.

@Snuffleupagus
Copy link
Collaborator

Patch updated. New version is deployed at https://mozilla.staktrace.com/tmp/fixzoom2/generic/web/viewer.html - please give it a whirl and let me know how it feels.

That's looks/feels much better, thank you!

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/b004d9813ca068a/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/b004d9813ca068a/output.txt

Total script time: 3.22 mins

Published

@timvandermeij timvandermeij merged commit 192afb8 into mozilla:master Aug 16, 2020
@timvandermeij
Copy link
Contributor

Thank you for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zoom is too sensitive on OS X
4 participants