Implement true smooth zooming on pdf.js
Categories
(Firefox :: PDF Viewer, enhancement, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox110 | --- | fixed |
People
(Reporter: kats, Assigned: calixte)
References
(Blocks 1 open bug)
Details
(Whiteboard: [pdfjs-zoom])
Attachments
(1 file)
Some types of inputs (e.g. doing a pinch-gesture on a touchscreen, a macOS trackpad, or high-precision windows/linux trackpad) should do a "smooth" zoom on pdf.js. Currently (as of bug 1643508) touchscreen pinches will do nothing, and the trackpad pinches will do a "stepwise" zoom, where the zoom factor goes up/down by 1.1x every so often.
This bug tracks implementing a "smooth" zoom where the zoom of the document tracks the pinch much more closely.
Comment 2•4 years ago
|
||
For someone implementing this, pdf.js already supports doing a CSS zoom where the canvas is scaled by using a CSS transforms first, then doing a full re-draw. We could reuse that by first using CSS zoom, then when the pinch zoom is done, re-draw.
Reporter | ||
Comment 3•4 years ago
|
||
Can you point me to the APIs that one would use to do this? I was trying to figure out the various setScale-related functions in base_viewer.js but it would probably be easier if you can say which ones would be appropriate here.
I think the only other significant change would be ensuring that the UI thingy that shows the current scale factor is updated appropriately, which I imagine shouldn't be too hard.
Comment 4•4 years ago
|
||
If you search for zoomLayer
in https://github.com/mozilla/pdf.js/blob/master/web/pdf_page_view.js you'll find the relevant bits. You can also enable only CSS zoom https://github.com/mozilla/pdf.js/blob/ebb903e5067b15081d2cf8e953996bf5ffb8da72/web/app_options.js#L147
Updated•3 years ago
|
Updated•3 years ago
|
I have a neuro issue where zooming animations reliably give me migraines and motion sickness, and smooth animations such as smooth scrolling, ease in-out, etc. also reliably give me migraines and motion sickness.
Since it's hard to avoid accidental zooming, I fear the combination will make me vomit onto the keyboard.
Comment 6•2 years ago
|
||
You know about the about:config pref apz.allow_zooming to disable normal pinch zooming?
Not pdf-specific, but there are a lot of sites which either zoom on mouseover, or zoom if users scroll, or zoom if users input data.
Comment 8•2 years ago
|
||
In pdf.js, we should be able to check the system's "prefers reduced motion" setting, and zoom in fixed increments (e.g. go from 100% directly to 120% rather than smoothly changing the zoom level from one to the other) in that case.
Another option would be to check general.smoothscroll, which has a front-end under about:preferences.
Updated•2 years ago
|
Updated•2 years ago
|
Comment 10•2 years ago
|
||
My understanding is that this bug was tracking making pinch-zooming smooth with both touchscreens and touchpads:
(In reply to Kartikaya Gupta (email:kats@mozilla.staktrace.com) from comment #0)
Some types of inputs (e.g. doing a pinch-gesture on a touchscreen, a macOS trackpad, or high-precision windows/linux trackpad) should do a "smooth" zoom on pdf.js. Currently (as of bug 1643508) touchscreen pinches will do nothing, and the trackpad pinches will do a "stepwise" zoom, where the zoom factor goes up/down by 1.1x every so often.
This bug tracks implementing a "smooth" zoom where the zoom of the document tracks the pinch much more closely.
Touchscreen zooming works nicely now, but touchpad pinch-zooming (tested on Linux Wayland) is still stepwise (zooms in 10% increments).
Calixte, should we reopen this?
Assignee | ||
Comment 11•2 years ago
|
||
Yep you're right we must fix the pinch-to-zoom on a trackpad to be complete.
Assignee | ||
Comment 12•2 years ago
|
||
Updated•2 years ago
|
Reporter | ||
Comment 13•2 years ago
|
||
For me on macOS 2023-01-09 nightly using the trackpad to zoom on a PDF zooms the entire content area, including the PDF toolbar component. That's not what I would expect (and not what I intended when I filed this bug). But I don't know, maybe that's the intended behaviour now?
Assignee | ||
Comment 14•2 years ago
|
||
:kats, I filed a bug about that:
https://bugzilla.mozilla.org/show_bug.cgi?id=1809080.
It should be fixed in nightly this week.
Updated•2 years ago
|
Comment 15•2 years ago
|
||
(In reply to Calixte Denizet (:calixte) from comment #11)
Yep you're right we must fix the pinch-to-zoom on a trackpad to be complete.
Thanks! Confirmed to be working well on Linux Wayland as well now.
Description
•