From 2464e7661c0b61f1a882b3b2817278c91d084edf Mon Sep 17 00:00:00 2001 From: nicwands Date: Thu, 25 Jun 2026 13:02:03 -0400 Subject: [PATCH] fix scroll update problem --- src/composables/useInfiniteScroll.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/composables/useInfiniteScroll.js b/src/composables/useInfiniteScroll.js index 018ca24..9e92f3d 100644 --- a/src/composables/useInfiniteScroll.js +++ b/src/composables/useInfiniteScroll.js @@ -179,19 +179,18 @@ export const useInfiniteScroll = (options = {}) => { scrollY: state.scrollY + deltaY, duration: 1, ease: 'expo.out', + onUpdate: async () => { + const newViewportIndex = calculateVisibleViewport(state.scrollY) + if (newViewportIndex !== state.currentViewportIndex) { + state.currentViewportIndex = newViewportIndex + const rangeStart = newViewportIndex - bufferSize + const rangeEnd = newViewportIndex + bufferSize + + await loadViewportsInRange(rangeStart, rangeEnd) + cleanupViewports() + } + }, }) - - const newViewportIndex = calculateVisibleViewport(state.scrollY) - - if (newViewportIndex !== state.currentViewportIndex) { - state.currentViewportIndex = newViewportIndex - - const rangeStart = newViewportIndex - bufferSize - const rangeEnd = newViewportIndex + bufferSize - - await loadViewportsInRange(rangeStart, rangeEnd) - cleanupViewports() - } } // Attach the virtual-scroll listener once Lenis is ready