From 89a1615cd151d503a4574a51139d523d54d157a2 Mon Sep 17 00:00:00 2001 From: Abishek Jayan Date: Sun, 25 Jun 2023 14:32:07 +0530 Subject: [PATCH] Reduce the amount scaled when using mouse-wheel zooming in Chromium-browsers (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 --- web/app.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/app.js b/web/app.js index 1ade1c6944975..add5300389405 100644 --- a/web/app.js +++ b/web/app.js @@ -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 ) {