1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Skip the scroll/scrollend workaround in the Firefox PDF Viewer (PR 17724 follow-up)

Given that [bug 1881974](https://bugzilla.mozilla.org/show_bug.cgi?id=1881974) has been fixed in Firefox 126, the workaround should no longer be necessary in the *built-in* Firefox PDF Viewer.
This commit is contained in:
Jonas Jenwald 2024-04-18 12:39:57 +02:00
parent 46a29ff41b
commit ff2e0c8afd

View file

@ -177,8 +177,6 @@ const PDFViewerApplication = {
_nimbusDataPromise: null,
_caretBrowsing: null,
_isScrolling: false,
_lastScrollTop: 0,
_lastScrollLeft: 0,
// Called once when the document is loaded.
async initialize(appConfig) {
@ -2002,15 +2000,20 @@ const PDFViewerApplication = {
) {
return;
}
// Using the values lastScrollTop and lastScrollLeft is a workaround to
// https://bugzilla.mozilla.org/show_bug.cgi?id=1881974.
// TODO: remove them once the bug is fixed.
({ scrollTop: this._lastScrollTop, scrollLeft: this._lastScrollLeft } =
mainContainer);
const scrollend = () => {
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
// Using the values lastScrollTop and lastScrollLeft is a workaround to
// https://bugzilla.mozilla.org/show_bug.cgi?id=1881974.
// TODO: remove them once the bug is fixed.
({ scrollTop: this._lastScrollTop, scrollLeft: this._lastScrollLeft } =
mainContainer);
}
const scrollend = () => {
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
({ scrollTop: this._lastScrollTop, scrollLeft: this._lastScrollLeft } =
mainContainer);
}
this._isScrolling = false;
mainContainer.addEventListener("scroll", scroll, {
passive: true,
@ -2020,13 +2023,17 @@ const PDFViewerApplication = {
mainContainer.removeEventListener("blur", scrollend, { signal });
};
const scroll = () => {
if (this._isCtrlKeyDown) {
return;
}
if (
this._isCtrlKeyDown ||
(this._lastScrollTop === mainContainer.scrollTop &&
this._lastScrollLeft === mainContainer.scrollLeft)
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
this._lastScrollTop === mainContainer.scrollTop &&
this._lastScrollLeft === mainContainer.scrollLeft
) {
return;
}
mainContainer.removeEventListener("scroll", scroll, {
passive: true,
signal,