monkeeShark/packages/frontend/src/components/MkNumber.vue
syuilo 37ef9b70a3
🎨
2022-12-31 21:10:25 +09:00

23 lines
438 B
Vue

<template>
<span>{{ number(Math.floor(tweened.number)) }}</span>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import gsap from 'gsap';
import number from '@/filters/number';
const props = defineProps<{
value: number;
}>();
const tweened = reactive({
number: 0,
});
watch(() => props.value, (n) => {
gsap.to(tweened, { duration: 1, number: Number(n) || 0 });
}, {
immediate: true,
});
</script>