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

Zoom relative to cursor position via mouse wheel #6170

Merged
merged 1 commit into from
Jul 3, 2015

Conversation

Rob--W
Copy link
Member

@Rob--W Rob--W commented Jul 2, 2015

Before this patch, zooming in/out via the scroll wheel caused the page to be zoomed relative to the upper-left corner of the page, i.e. the upper-left corner of the page stays at a fixed position.

After this patch, the page is zoomed relative to the cursor position, i.e. after zooming in/out, the part under the cursor 'has not moved'.

This only applies when the page does not fit in the viewport, because pages smaller than the viewpoer are always centered.

To verify that the patch works as intended:

  1. Open the viewer.
  2. Resize (shrink) the window if you have a huge screen until the PDF does not fully fit in the viewport.
  3. Use the mouse wheel to zoom in at a letter.
  4. Zoom out while the page is still bigger than the viewport.

During step 3 and 4, the PDF under the page position under the cursor should be fixed.

Before this patch, zooming in/out via the scroll wheel caused the page
to be zoomed relative to the upper-left corner of the page, i.e. the
upper-left corner of the page stays at a fixed position.

After this patch, the page is zoomed relative to the cursor position,
i.e. after zooming in/out, the part under the cursor 'has not moved'.

This only applies when the page does not fit in the viewport, because
pages smaller than the viewpoer are always centered.
@Rob--W Rob--W added the viewer label Jul 2, 2015
@yurydelendik
Copy link
Contributor

/botio-windows preview

@pdfjsbot
Copy link

pdfjsbot commented Jul 2, 2015

From: Bot.io (Windows)


Received

Command cmd_preview from @yurydelendik received. Current queue size: 1

Live output at: http://107.22.172.223:8877/25830a6f1c76237/output.txt

@Rob--W
Copy link
Member Author

Rob--W commented Jul 3, 2015

I had previously verified that the patch works in Firefox 38 and Chromium 43 on Linux.

Now I've also manually tested this patch in various browsers/OSs at BrowserStack, by visiting http://107.22.172.223:8877/25830a6f1c76237/web/viewer.html and following the steps in the PR description.
Unless stated otherwise, the patch "works as intended", i.e. upon zooming in/out, the part under the cursor is almost fixed (due to conversions from pixels to PDF pixels, and rounding errors, the location can be off by a few pixels after zooming in/out several times).

Windows 7

  • Chrome 45
  • Firefox 40
  • IE 9
  • IE 11
  • Opera 31

Windows 10

  • Chrome 43
  • Edge 0.11
  • Firefox 40

OS X 10.8 (Mountain Lion)

  • Safari 6

OS X 10.9 (Mavericks)

  • Safari 7

OS X 10.10 (Yosemite)

  • Chrome 45
  • Firefox 40 (scrolling 1 tick works fine, scrolling multiple ticks at once causes the position to be off by a few tens of pixels. Someone with a real Mac should check whether this issue exists on their machine, or whether it's just a bug with the setup on Browserstack)
  • Safari 8 (same as in Firefox)

@yurydelendik Could you check whether this PR works fine on OS X in Firefox & Safari? If yes, then the PR can be merged.

@yurydelendik
Copy link
Contributor

It works on ff & safari. Thank you for the patch.

yurydelendik added a commit that referenced this pull request Jul 3, 2015
Zoom relative to cursor position via mouse wheel
@yurydelendik yurydelendik merged commit 3ffed9d into mozilla:master Jul 3, 2015
@timvandermeij
Copy link
Contributor

Nice feature, thank you @Rob--W!

@Andersw88
Copy link

This patch works fine when testing
http://107.22.172.223:8877/25830a6f1c76237/web/viewer.html
but not on most PDFs like
https://www.adobe.com/enterprise/accessibility/pdfs/acro6_pg_ue.pdf

Running
Ubuntu 14.04 LTS
Firefox 41.0

@Snuffleupagus
Copy link
Collaborator

@Andersw88 This patch will be included in Firefox 42 (according to the "Target Milestone" field in bug 1182228), which is scheduled for release on 2015-11-03.

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.

6 participants