nkoik / vue-animated-number

:1234: This is a Vue number plugin. It animates the number that you pass in prop.
MIT License
74 stars 15 forks source link

Chrome bug with dynamic component won't replay animation #29

Open duyn-stanford opened 1 month ago

duyn-stanford commented 1 month ago

I'm using Vue 3 composition API. I have a toggle that dynamically loads a component (using <component :is="MyComponent">) that includes the vue-animated-number component. The first time I load the component, the animation plays fine. However, when I toggle out of the component and back to the component, the vue-animated-number value stays at 0 and does not replay. It works fine in Safari. The custom component uses a pretty standard configuration for vue-animated-number:

<script setup>
import NumberAnimation from 'vue-number-animation';

defineProps(['value']);

function format(num) {
    const formatter = new Intl.NumberFormat('en-US');

    return formatter.format(Number.parseInt(num).toFixed(0));
}
</script>

<template>
    <NumberAnimation :to="value" :format="format" :duration="0.3" /> 
</template>

I was hoping others might have come across this issue.

duyn-stanford commented 1 month ago

I guess the issue might have to do with setting the duration to 0.3. This works fine when the duration prop is not set (albeit a 1 second animation is not desirable).