Disconnect the resize observer and remove scroll listener when unbinding window events

This commit is contained in:
Calixte Denizet 2024-05-30 18:53:07 +02:00
parent fdb3617e0f
commit 4430b6b703
4 changed files with 35 additions and 4 deletions

View file

@ -309,7 +309,21 @@ class PDFViewer {
this.renderingQueue = options.renderingQueue;
}
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this));
const { abortSignal } = options;
abortSignal?.addEventListener(
"abort",
() => {
this.#resizeObserver.disconnect();
this.#resizeObserver = null;
},
{ once: true }
);
this.scroll = watchScroll(
this.container,
this._scrollUpdate.bind(this),
abortSignal
);
this.presentationModeState = PresentationModeState.UNKNOWN;
this._resetView();