From 4a628a39ffcef6d4ce711a8a23551bc7a09eb564 Mon Sep 17 00:00:00 2001 From: Kael Date: Mon, 9 Dec 2024 15:48:02 +1100 Subject: [PATCH] fix(virtual): add fallback scrollend timeout closes #20566 closes #20757 --- packages/vuetify/src/composables/virtual.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/vuetify/src/composables/virtual.ts b/packages/vuetify/src/composables/virtual.ts index d92b5a01678..dd2eee76ede 100644 --- a/packages/vuetify/src/composables/virtual.ts +++ b/packages/vuetify/src/composables/virtual.ts @@ -149,6 +149,7 @@ export function useVirtual (props: VirtualProps, items: Ref) { } }) + let scrollTimeout = -1 function handleScroll () { if (!containerRef.value || !markerRef.value) return @@ -169,6 +170,9 @@ export function useVirtual (props: VirtualProps, items: Ref) { lastScrollTop = scrollTop lastScrollTime = scrollTime + clearTimeout(scrollTimeout) + scrollTimeout = setTimeout(handleScrollend, 500) + calculateVisibleItems() } function handleScrollend () { @@ -177,6 +181,7 @@ export function useVirtual (props: VirtualProps, items: Ref) { scrollVelocity = 0 lastScrollTime = 0 + clearTimeout(scrollTimeout) calculateVisibleItems() }