Skip to content

Commit

Permalink
fix(VVirtualScroll): reset scroll velocity when height changes
Browse files Browse the repository at this point in the history
fixes #18918
  • Loading branch information
KaelWD committed Feb 15, 2024
1 parent 4923e53 commit cb62963
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/vuetify/src/composables/virtual.ts
Expand Up @@ -107,9 +107,6 @@ export function useVirtual <T> (props: VirtualProps, items: Ref<readonly T[]>) {
})
})
})
watch(viewportHeight, (val, oldVal) => {
oldVal && calculateVisibleItems()
})

onScopeDispose(() => {
updateOffsets.clear()
Expand Down Expand Up @@ -139,6 +136,19 @@ export function useVirtual <T> (props: VirtualProps, items: Ref<readonly T[]>) {
let lastScrollTop = 0
let scrollVelocity = 0
let lastScrollTime = 0

watch(viewportHeight, (val, oldVal) => {
if (oldVal) {
calculateVisibleItems()
if (val < oldVal) {
requestAnimationFrame(() => {
scrollVelocity = 0
calculateVisibleItems()
})
}
}
})

function handleScroll () {
if (!containerRef.value || !markerRef.value) return

Expand Down

0 comments on commit cb62963

Please sign in to comment.