diff --git a/src/components/lazyLoader/lazyLoaderIntersectionObserver.js b/src/components/lazyLoader/lazyLoaderIntersectionObserver.js index 81378710ff2..8a3835d8902 100644 --- a/src/components/lazyLoader/lazyLoaderIntersectionObserver.js +++ b/src/components/lazyLoader/lazyLoaderIntersectionObserver.js @@ -7,10 +7,10 @@ export class LazyLoader { createObserver() { const callback = this.options.callback; - const observer = new IntersectionObserver( - (entries) => { + const newObserver = new IntersectionObserver( + (entries, observer) => { entries.forEach(entry => { - callback(entry); + callback(entry, observer); }); }, { @@ -18,7 +18,7 @@ export class LazyLoader { threshold: 0 }); - this.observer = observer; + this.observer = newObserver; } addElements(elements) { diff --git a/src/controllers/movies/moviegenres.js b/src/controllers/movies/moviegenres.js index 9a45f59e06f..b9fa8bc5003 100644 --- a/src/controllers/movies/moviegenres.js +++ b/src/controllers/movies/moviegenres.js @@ -52,8 +52,14 @@ export default function (view, params, tabContent) { return !layoutManager.desktop; } - const fillItemsContainer = (entry) => { + const fillItemsContainer = (entry, observer) => { + if (!entry.isIntersecting) { + return; + } + const elem = entry.target; + observer.unobserve(elem); + const id = elem.getAttribute('data-id'); const viewStyle = this.getCurrentViewStyle(); let limit = viewStyle == 'Thumb' || viewStyle == 'ThumbCard' ? 5 : 9; diff --git a/src/controllers/shows/tvgenres.js b/src/controllers/shows/tvgenres.js index c1c360a8319..6c598262704 100644 --- a/src/controllers/shows/tvgenres.js +++ b/src/controllers/shows/tvgenres.js @@ -52,8 +52,14 @@ export default function (view, params, tabContent) { return !layoutManager.desktop; } - function fillItemsContainer(entry) { + function fillItemsContainer(entry, observer) { + if (!entry.isIntersecting) { + return; + } + const elem = entry.target; + observer.unobserve(elem); + const id = elem.getAttribute('data-id'); const viewStyle = self.getCurrentViewStyle(); let limit = viewStyle == 'Thumb' || viewStyle == 'ThumbCard' ? 5 : 9;