mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 06:38:07 +02:00
Remove the sidebar resizing event listeners with an AbortController
This commit is contained in:
parent
7619171265
commit
be685a293c
1 changed files with 9 additions and 9 deletions
|
@ -69,9 +69,7 @@ const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
||||||
class PDFSidebar {
|
class PDFSidebar {
|
||||||
#isRTL = false;
|
#isRTL = false;
|
||||||
|
|
||||||
#mouseMoveBound = this.#mouseMove.bind(this);
|
#mouseAC = null;
|
||||||
|
|
||||||
#mouseUpBound = this.#mouseUp.bind(this);
|
|
||||||
|
|
||||||
#outerContainerWidth = null;
|
#outerContainerWidth = null;
|
||||||
|
|
||||||
|
@ -422,9 +420,12 @@ class PDFSidebar {
|
||||||
// in order to improve responsiveness and to avoid visual glitches.
|
// in order to improve responsiveness and to avoid visual glitches.
|
||||||
outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
|
outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
|
||||||
|
|
||||||
window.addEventListener("mousemove", this.#mouseMoveBound);
|
this.#mouseAC = new AbortController();
|
||||||
window.addEventListener("mouseup", this.#mouseUpBound);
|
const opts = { signal: this.#mouseAC.signal };
|
||||||
window.addEventListener("blur", this.#mouseUpBound);
|
|
||||||
|
window.addEventListener("mousemove", this.#mouseMove.bind(this), opts);
|
||||||
|
window.addEventListener("mouseup", this.#mouseUp.bind(this), opts);
|
||||||
|
window.addEventListener("blur", this.#mouseUp.bind(this), opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus._on("resize", evt => {
|
eventBus._on("resize", evt => {
|
||||||
|
@ -505,9 +506,8 @@ class PDFSidebar {
|
||||||
// ... and ensure that rendering will always be triggered.
|
// ... and ensure that rendering will always be triggered.
|
||||||
this.eventBus.dispatch("resize", { source: this });
|
this.eventBus.dispatch("resize", { source: this });
|
||||||
|
|
||||||
window.removeEventListener("mousemove", this.#mouseMoveBound);
|
this.#mouseAC?.abort();
|
||||||
window.removeEventListener("mouseup", this.#mouseUpBound);
|
this.#mouseAC = null;
|
||||||
window.removeEventListener("blur", this.#mouseUpBound);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue