Skip to content

Commit

Permalink
fix(useTransition): call pause() to stop useRafFn when disabling (#2360)
Browse files Browse the repository at this point in the history
Co-authored-by: 李众豪 <lizhonghao@fsyhlz.com>
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
3 people committed Nov 9, 2022
1 parent f00fdc5 commit 0a49ea4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/core/useTransition/index.ts
Expand Up @@ -199,15 +199,19 @@ export function useTransition(
const timeout = useTimeoutFn(start, delay, { immediate: false })

watch(sourceVector, () => {
if (unref(disabled)) {
if (unref(disabled))
return
if (unref(delay) <= 0)
start()
else timeout.start()
}, { deep: true })

watch(() => unref(disabled), (v) => {
if (v) {
outputVector.value = sourceVector.value.slice(0)
pause()
}
else {
if (unref(delay) <= 0)
start()
else timeout.start()
}
}, { deep: true })
})

return computed(() => {
const targetVector = unref(disabled) ? sourceVector : outputVector
Expand Down

0 comments on commit 0a49ea4

Please sign in to comment.