diff --git a/web/app.js b/web/app.js index e9d40b0e249142..08f698d5e793d5 100644 --- a/web/app.js +++ b/web/app.js @@ -165,6 +165,8 @@ const PDFViewerApplication = { _isCtrlKeyDown: false, _nimbusDataPromise: null, _caretBrowsing: null, + _isScrolling: false, + _isScrollEndSupported: true, // Called once when the document is loaded. async initialize(appConfig) { @@ -683,6 +685,33 @@ const PDFViewerApplication = { } else { throw new Error("Not implemented: run"); } + + if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) { + this._isScrollEndSupported = "onscrollend" in document.documentElement; + } + if ( + (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) || + this._isScrollEndSupported + ) { + const { mainContainer } = appConfig; + mainContainer.addEventListener( + "scroll", + () => { + if (this._isScrolling) { + return; + } + this._isScrolling = true; + mainContainer.addEventListener( + "scrollend", + () => { + this._isScrolling = false; + }, + { once: true } + ); + }, + { passive: true } + ); + } }, get externalServices() { @@ -2653,6 +2682,7 @@ function webViewerWheel(evt) { evt.preventDefault(); // NOTE: this check must be placed *after* preventDefault. if ( + PDFViewerApplication._isScrolling || zoomDisabledTimeout || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active @@ -2718,7 +2748,10 @@ function webViewerWheel(evt) { // left corner is restored. When the mouse wheel is used, the position // under the cursor should be restored instead. PDFViewerApplication._centerAtPos(previousScale, evt.clientX, evt.clientY); - } else { + } else if ( + (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) && + !PDFViewerApplication._isScrollEndSupported + ) { setZoomDisabledTimeout(); } }