Skip to content

Commit

Permalink
Reduce the amount scaled when using mouse-wheel zooming in Chromium-b…
Browse files Browse the repository at this point in the history
…rowsers (issue 16325)

So I have found that rather than messing with the delta values, the simplest way to solve the problem would be to find a clean way to
detect if the browser was Chromium or not. I found that chromium browsers have a property called windows.chrome which on console logging, looks something like this:

{
        app: {
            isInstalled: false,
            InstallState: {
                DISABLED: disabled,
                INSTALLED: installed,
                NOT_INSTALLED: not_installed
            },
            RunningState: {
                CANNOT_RUN: cannot_run,
                READY_TO_RUN: ready_to_run,
                RUNNING: running
            }
        },
        appPinningPrivate: {}
}

Whereas in firefox, logging that property returns undefined. I had searched to see if there were ways that the window.chrome property could be faked (since the navigator.userAgent could be faked) but I couldnt find anything regarding that. Whats more, Edge, Opera, Brave and Chrome all support this property as per https://stackoverflow.com/a/13348618

So the current fix just adds the windows.chrome check to the if condition at line 2762.

I had tested this functionality myself on all these browsers and they work as intended in both desktop and mobile versions.

Update: Added PDFJSDev checks to ensure no unnecessary code ends up in
the built-in Firefox PDF Viewer
  • Loading branch information
Abishek-Jayan committed Jun 25, 2023
1 parent 0bbadce commit 89a1615
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2760,6 +2760,9 @@ function webViewerWheel(evt) {

let ticks = 0;
if (
(typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("GENERIC || CHROME") &&
window.chrome) ||
deltaMode === WheelEvent.DOM_DELTA_LINE ||
deltaMode === WheelEvent.DOM_DELTA_PAGE
) {
Expand Down

0 comments on commit 89a1615

Please sign in to comment.