From c92ba393c2934b0b29b2d6e993484529b281252a Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 8 Feb 2023 14:31:28 +0100 Subject: [PATCH] Fix pinch-to-zoom on mac for the Firefox builtin viewer In the mac case we don't want to care about the scaleFactor threshold because else if too big another move could start and then subsequent events aren't considered as wheel events. It isn't really ideal and at some point we'll need to find a way at least for the Firefox case to get the real events instead of the fake wheel ones. --- src/pdf.js | 2 ++ web/app.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pdf.js b/src/pdf.js index a07828441..44a0dfe67 100644 --- a/src/pdf.js +++ b/src/pdf.js @@ -32,6 +32,7 @@ import { CMapCompressionType, createPromiseCapability, createValidAbsoluteUrl, + FeatureTest, InvalidPDFException, MissingPDFException, OPS, @@ -89,6 +90,7 @@ export { CMapCompressionType, createPromiseCapability, createValidAbsoluteUrl, + FeatureTest, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, diff --git a/web/app.js b/web/app.js index 85759cbb0..243b16cf7 100644 --- a/web/app.js +++ b/web/app.js @@ -38,6 +38,7 @@ import { AnnotationEditorType, build, createPromiseCapability, + FeatureTest, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, @@ -2695,12 +2696,16 @@ function webViewerWheel(evt) { // https://searchfox.org/mozilla-central/rev/d62c4c4d5547064487006a1506287da394b64724/widget/InputData.cpp#618-626 let scaleFactor = Math.exp(-evt.deltaY / 100); + const isBuiltInMac = + typeof PDFJSDev !== "undefined" && + PDFJSDev.test("MOZCENTRAL") && + FeatureTest.platform.isMac; const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && - Math.abs(scaleFactor - 1) < 0.05 && + (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0; if (