fix: 修复因变化快无法显示反动动画效果

This commit is contained in:
tnt group 2023-05-14 12:34:21 +08:00
parent 02c1bd30e3
commit f9c3d978f0

View File

@ -6,7 +6,7 @@
</template>
<script lang="ts" setup>
import { ref, PropType, watch } from 'vue'
import { ref, PropType, watch, nextTick } from 'vue'
import { FlipType } from './index'
const props = defineProps({
@ -57,18 +57,19 @@ const backTextFromData = ref(props.count || 0)
let timeoutID: any = 0
//
const flip = (front: string | number, back: string | number) => {
//
backTextFromData.value = back
frontTextFromData.value = front
const flip = async (front: string | number, back: string | number) => {
//
if (isFlipping.value) {
isFlipping.value = false //
clearTimeout(timeoutID) //
flip(front, back) //
await nextTick()
await flip(front, back) //
return
}
//
backTextFromData.value = back
frontTextFromData.value = front
// true
isFlipping.value = true