diff --git a/src/index.ts b/src/index.ts index 4ccdbc2..fc5d6b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,7 @@ export interface IOptions { } type StateForRoot = { - elements: [HTMLElement]; + elements: HTMLElement[]; options: IOptions; intersectionObserver: any; }; @@ -61,6 +61,11 @@ export default class IntersectionObserverAdmin extends Notifications { if (matchingRootEntry) { const { intersectionObserver } = matchingRootEntry; intersectionObserver.unobserve(target); + + const elIndex = matchingRootEntry.elements.indexOf(target); + if (elIndex !== -1) { + matchingRootEntry.elements.splice(elIndex, 1); + } } }