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