Skip to content

Commit

Permalink
perf: educe the unnecessary use of ref (#526)
Browse files Browse the repository at this point in the history
Co-authored-by: Sanjay Soundarajan <[email protected]>
  • Loading branch information
Mini-ghost and megasanjay authored Mar 17, 2024
1 parent 171d54f commit f1502e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/vue3-lottie/src/vue3-lottie.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ export default defineComponent({
},
setup(props, { emit: emits }) {
const animationData = ref<any>()
const lottieAnimationContainer = ref<HTMLDivElement>()
let animationData: any
let lottieAnimation: AnimationItem | null = null
let direction: AnimationDirection = 1
Expand All @@ -131,14 +131,14 @@ export default defineComponent({
const responseJSON = await response.json()
animationData.value = responseJSON
animationData = responseJSON
} catch (error) {
console.error(error)
return
}
} else if (isEqual(props.animationData, {}) === false) {
// clone the animationData to prevent it from being mutated
animationData.value = cloneDeep(props.animationData)
animationData = cloneDeep(props.animationData)
} else {
throw new Error(
'You must provide either animationLink or animationData',
Expand All @@ -153,7 +153,7 @@ export default defineComponent({
if (!lottieAnimationContainer.value) return
// check if the animationData has been loaded
if (!animationData.value) return
if (!animationData) return
// destroy the animation if it already exists
lottieAnimation?.destroy()
Expand Down Expand Up @@ -187,7 +187,7 @@ export default defineComponent({
renderer: props.renderer,
loop: loop,
autoplay: autoPlay,
animationData: animationData.value,
animationData: animationData,
assetsPath: props.assetsPath,
}
Expand Down

0 comments on commit f1502e9

Please sign in to comment.