Register images for Lazy loading after rendering during infinite scrolling

This commit is contained in:
HighImKevin committed 2026-10-02 05:56:23 -04:00
1 parent 41144d1323
commit e1f6272f51
1 file changed
+4 -15
+4 -15
View File
@@ -569,6 +569,9 @@
card.setAttribute('data-index', startIndex + index);
container.appendChild(card);
});
if (typeof window.cardBuilder.registerLazyImagesIn === 'function') {
window.cardBuilder.registerLazyImagesIn(container);
}
LOG('Cards built successfully');
}
@@ -660,13 +663,12 @@
function checkScrollPosition() {
// Don't trigger if already loading, no more items, or request in progress
if (loading || !hasMore || isScrollTriggered || isRequestInProgress) {
LOG('Scroll check blocked:', { loading, hasMore, isScrollTriggered, isRequestInProgress });
return;
}
// Don't trigger when not on a supported page
const container = getContainer();
if (!container) {
LOG('No container found in scroll check');
return;
}
@@ -685,19 +687,6 @@
const distanceFromBottom = documentHeight - (scrollTop + windowHeight);
const triggerThreshold = windowHeight; // One viewport height from bottom
LOG('Scroll check:', {
scrollTop,
windowHeight,
documentHeight,
distanceFromBottom,
triggerThreshold,
existingItemsCount,
loading,
hasMore,
isScrollTriggered,
isRequestInProgress
});
if (distanceFromBottom <= triggerThreshold) {
isScrollTriggered = true;
LOG('Triggering loadMore from scroll (one viewport height from bottom)');