From e1f6272f51cb27217269f0ba27effad34be44d41 Mon Sep 17 00:00:00 2001 From: HighImKevin Date: Fri, 2 Oct 2026 05:56:23 -0400 Subject: [PATCH] Register images for Lazy loading after rendering during infinite scrolling --- scripts/infiniteScroll.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/scripts/infiniteScroll.js b/scripts/infiniteScroll.js index 5f18a3d..be7a9d3 100644 --- a/scripts/infiniteScroll.js +++ b/scripts/infiniteScroll.js @@ -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)');