Skip to content

Commit e866592

Browse files
Mrlilililiyan1
andauthored
fix(useAnimate): Correct condition for updating keyframes (#4619)
Co-authored-by: liyan1 <liyan1@joyy.com>
1 parent 13393b1 commit e866592

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packages/core/useAnimate/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,17 @@ export function useAnimate(
233233
})
234234

235235
watch(() => keyframes, (value) => {
236-
if (animate.value)
236+
if (animate.value) {
237237
update()
238238

239-
if (!unrefElement(target) && animate.value) {
240-
animate.value.effect = new KeyframeEffect(
241-
unrefElement(target)!,
242-
toValue(value),
243-
animateOptions,
244-
)
239+
const targetEl = unrefElement(target)
240+
if (targetEl) {
241+
animate.value.effect = new KeyframeEffect(
242+
targetEl,
243+
toValue(value),
244+
animateOptions,
245+
)
246+
}
245247
}
246248
}, { deep: true })
247249

0 commit comments

Comments
 (0)