diff --git a/packages/vuetify/src/composables/virtual.ts b/packages/vuetify/src/composables/virtual.ts index d92b5a01678..940d78b2f17 100644 --- a/packages/vuetify/src/composables/virtual.ts +++ b/packages/vuetify/src/composables/virtual.ts @@ -136,6 +136,8 @@ export function useVirtual (props: VirtualProps, items: Ref) { let lastScrollTop = 0 let scrollVelocity = 0 let lastScrollTime = 0 + let lastItemsChange = 0 + let forcedScrollendTimeout = 0 as any watch(viewportHeight, (val, oldVal) => { if (oldVal) { @@ -169,6 +171,13 @@ export function useVirtual (props: VirtualProps, items: Ref) { lastScrollTop = scrollTop lastScrollTime = scrollTime + // while scroll event is triggered upon items change + // the scrollend event does not trigger automatically + clearTimeout(forcedScrollendTimeout) + if (scrollTime - lastItemsChange < 300) { + forcedScrollendTimeout = setTimeout(handleScrollend, 100) + } + calculateVisibleItems() } function handleScrollend () { @@ -237,6 +246,7 @@ export function useVirtual (props: VirtualProps, items: Ref) { }) watch(items, () => { + lastItemsChange = performance.now() sizes = Array.from({ length: items.value.length }) offsets = Array.from({ length: items.value.length }) updateOffsets.immediate()