Skip to content

Commit

Permalink
fix(virtual): add fallback scrollend timeout
Browse files Browse the repository at this point in the history
closes #20566
closes #20757
  • Loading branch information
KaelWD committed Dec 9, 2024
1 parent ca85fc0 commit 4a628a3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/vuetify/src/composables/virtual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export function useVirtual <T> (props: VirtualProps, items: Ref<readonly T[]>) {
}
})

let scrollTimeout = -1
function handleScroll () {
if (!containerRef.value || !markerRef.value) return

Expand All @@ -169,6 +170,9 @@ export function useVirtual <T> (props: VirtualProps, items: Ref<readonly T[]>) {
lastScrollTop = scrollTop
lastScrollTime = scrollTime

clearTimeout(scrollTimeout)
scrollTimeout = setTimeout(handleScrollend, 500)

calculateVisibleItems()
}
function handleScrollend () {
Expand All @@ -177,6 +181,7 @@ export function useVirtual <T> (props: VirtualProps, items: Ref<readonly T[]>) {
scrollVelocity = 0
lastScrollTime = 0

clearTimeout(scrollTimeout)
calculateVisibleItems()
}

Expand Down

0 comments on commit 4a628a3

Please # to comment.