Skip to content

Commit

Permalink
fix(drop-down-menu): fix cannot clear throttle timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
stfsy committed Apr 20, 2023
1 parent d87ef33 commit 7ba21b7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/drop-down-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const props = defineProps({
}
})
const throttle = createThrottleFn()
const throttleFactory = createThrottleFn()
const throttle = throttleFactory(checkNeedToCalculatePosition, 50)
let isListeningToScrolls = false
const scrollEvent = 'scroll'
const menu = ref()
Expand All @@ -41,7 +42,7 @@ onBeforeUnmount(() => {
function activateScrollListenerIfInactive() {
if (!isListeningToScrolls) {
isListeningToScrolls = true
window.addEventListener(scrollEvent, throttle(checkNeedToCalculatePosition, 50), { passive: true })
window.addEventListener(scrollEvent, throttle, { passive: true })
}
}
Expand Down

0 comments on commit 7ba21b7

Please sign in to comment.