Fix lazy loading on the genre pages (#6799)
* Fix genre tab from sorting shows randomly * Fix loading elements that have already been loaded * Fix lazyLoader for show and movie genre tabs * Reduce time window in which callback may be executed again
This commit is contained in:
committed by
GitHub
parent
da7135e77a
commit
d190fdb27c
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user