Skip to content

Commit

Permalink
perf(VOverlay): only add resize listener when overlay is open
Browse files Browse the repository at this point in the history
closes #18372
  • Loading branch information
KaelWD committed Dec 2, 2023
1 parent b52e935 commit ca2174c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/vuetify/src/components/VOverlay/locationStrategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,18 @@ export function useLocationStrategies (
useToggleScope(() => !!(data.isActive.value && props.locationStrategy), reset => {
watch(() => props.locationStrategy, reset)
onScopeDispose(() => {
window.removeEventListener('resize', onResize)
updateLocation.value = undefined
})

window.addEventListener('resize', onResize, { passive: true })

if (typeof props.locationStrategy === 'function') {
updateLocation.value = props.locationStrategy(data, props, contentStyles)?.updateLocation
} else {
updateLocation.value = locationStrategies[props.locationStrategy](data, props, contentStyles)?.updateLocation
}
})

window.addEventListener('resize', onResize, { passive: true })

onScopeDispose(() => {
window.removeEventListener('resize', onResize)
updateLocation.value = undefined
})
}

function onResize (e: Event) {
Expand Down

0 comments on commit ca2174c

Please sign in to comment.