fix: 修复因变化快无法显示反动动画效果
This commit is contained in:
parent
02c1bd30e3
commit
f9c3d978f0
@ -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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user