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:
parent
46a29ff41b
commit
ff2e0c8afd
31
web/app.js
31
web/app.js
@ -177,8 +177,6 @@ const PDFViewerApplication = {
|
|||||||
_nimbusDataPromise: null,
|
_nimbusDataPromise: null,
|
||||||
_caretBrowsing: null,
|
_caretBrowsing: null,
|
||||||
_isScrolling: false,
|
_isScrolling: false,
|
||||||
_lastScrollTop: 0,
|
|
||||||
_lastScrollLeft: 0,
|
|
||||||
|
|
||||||
// Called once when the document is loaded.
|
// Called once when the document is loaded.
|
||||||
async initialize(appConfig) {
|
async initialize(appConfig) {
|
||||||
@ -2002,15 +2000,20 @@ const PDFViewerApplication = {
|
|||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||||
// Using the values lastScrollTop and lastScrollLeft is a workaround to
|
// Using the values lastScrollTop and lastScrollLeft is a workaround to
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1881974.
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1881974.
|
||||||
// TODO: remove them once the bug is fixed.
|
// TODO: remove them once the bug is fixed.
|
||||||
({ scrollTop: this._lastScrollTop, scrollLeft: this._lastScrollLeft } =
|
|
||||||
mainContainer);
|
|
||||||
const scrollend = () => {
|
|
||||||
({ scrollTop: this._lastScrollTop, scrollLeft: this._lastScrollLeft } =
|
({ scrollTop: this._lastScrollTop, scrollLeft: this._lastScrollLeft } =
|
||||||
mainContainer);
|
mainContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
const scrollend = () => {
|
||||||
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||||
|
({ scrollTop: this._lastScrollTop, scrollLeft: this._lastScrollLeft } =
|
||||||
|
mainContainer);
|
||||||
|
}
|
||||||
|
|
||||||
this._isScrolling = false;
|
this._isScrolling = false;
|
||||||
mainContainer.addEventListener("scroll", scroll, {
|
mainContainer.addEventListener("scroll", scroll, {
|
||||||
passive: true,
|
passive: true,
|
||||||
@ -2020,13 +2023,17 @@ const PDFViewerApplication = {
|
|||||||
mainContainer.removeEventListener("blur", scrollend, { signal });
|
mainContainer.removeEventListener("blur", scrollend, { signal });
|
||||||
};
|
};
|
||||||
const scroll = () => {
|
const scroll = () => {
|
||||||
|
if (this._isCtrlKeyDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
this._isCtrlKeyDown ||
|
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
|
||||||
(this._lastScrollTop === mainContainer.scrollTop &&
|
this._lastScrollTop === mainContainer.scrollTop &&
|
||||||
this._lastScrollLeft === mainContainer.scrollLeft)
|
this._lastScrollLeft === mainContainer.scrollLeft
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mainContainer.removeEventListener("scroll", scroll, {
|
mainContainer.removeEventListener("scroll", scroll, {
|
||||||
passive: true,
|
passive: true,
|
||||||
signal,
|
signal,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user