mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Disconnect the resize observer and remove scroll listener when unbinding window events
This commit is contained in:
parent
fdb3617e0f
commit
4430b6b703
4 changed files with 35 additions and 4 deletions
|
@ -155,7 +155,7 @@ function scrollIntoView(element, spot, scrollMatches = false) {
|
|||
* Helper function to start monitoring the scroll event and converting them into
|
||||
* PDF.js friendly one: with scroll debounce and scroll direction.
|
||||
*/
|
||||
function watchScroll(viewAreaElement, callback) {
|
||||
function watchScroll(viewAreaElement, callback, abortSignal = undefined) {
|
||||
const debounceScroll = function (evt) {
|
||||
if (rAF) {
|
||||
return;
|
||||
|
@ -189,7 +189,10 @@ function watchScroll(viewAreaElement, callback) {
|
|||
};
|
||||
|
||||
let rAF = null;
|
||||
viewAreaElement.addEventListener("scroll", debounceScroll, true);
|
||||
viewAreaElement.addEventListener("scroll", debounceScroll, {
|
||||
useCapture: true,
|
||||
signal: abortSignal,
|
||||
});
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue