fix: infinite scroll sneller — rootMargin 1200px + 3 batches per trigger
Was: rootMargin=200px, 1 batch (50 items) per intersection trigger → bij snel scrollen moest je wachten of terugscrollen Nu: rootMargin=1200px, tot 3 batches (150 items) per trigger → sentinel wordt 1200px eerder gedetecteerd, batches pre-loaden agressief → sentinel blijft ver voor de viewport, nooit meer wachten
This commit is contained in:
parent
cb5bb43453
commit
b6c89e548d
1 changed files with 9 additions and 2 deletions
|
|
@ -2771,9 +2771,16 @@ button:active, .btn:active, .meal-card-main:active, .dagboek-item:active, .food-
|
|||
|
||||
searchObserver = new IntersectionObserver((entries) => {
|
||||
if (entries[0].isIntersecting) {
|
||||
appendSearchBatch(allItems);
|
||||
// Load up to 3 batches at once when user scrolls fast
|
||||
// This keeps the sentinel pushed far ahead of the viewport
|
||||
let batchesLoaded = 0;
|
||||
const maxBatches = 3;
|
||||
while (batchesLoaded < maxBatches && searchVisibleCount < allItems.length) {
|
||||
appendSearchBatch(allItems);
|
||||
batchesLoaded++;
|
||||
}
|
||||
}
|
||||
}, { rootMargin: '200px' });
|
||||
}, { rootMargin: '1200px' });
|
||||
|
||||
searchObserver.observe(sentinel);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue