2023-02-14 13:02:41 +09:00
|
|
|
<template>
|
2023-04-08 09:01:42 +09:00
|
|
|
<span>{{ number(Math.floor(tweened.number)) }}</span>
|
2023-02-14 13:02:41 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-04-08 09:01:42 +09:00
|
|
|
import { ref, reactive, watch } from "vue";
|
|
|
|
import gsap from "gsap";
|
|
|
|
import number from "@/filters/number";
|
2023-02-14 13:02:41 +09:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
value: number;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const tweened = reactive({
|
|
|
|
number: 0,
|
|
|
|
});
|
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
watch(
|
|
|
|
() => props.value,
|
|
|
|
(n) => {
|
|
|
|
gsap.to(tweened, { duration: 0.6, number: Number(n) || 0 });
|
|
|
|
},
|
|
|
|
{
|
|
|
|
immediate: true,
|
|
|
|
}
|
|
|
|
);
|
2023-02-14 13:02:41 +09:00
|
|
|
</script>
|