File tree 1 file changed +7
-8
lines changed
1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -57,17 +57,15 @@ const initCountUp = () => {
57
57
}
58
58
emits (' init' , countUp .value )
59
59
}
60
- let loopCount = 0
61
60
// 开始动画
62
61
const startAnim = () => {
63
62
countUp .value ?.start ()
64
- loopCount ++
65
63
checkAnimateState ()
66
64
}
67
65
// 循环动画
66
+ let loopCount = 1
68
67
const loopAnim = () => {
69
68
loopCount ++
70
- // console.log('loop', loopCount)
71
69
finished .value = false
72
70
countUp .value ?.reset ()
73
71
startAnim ()
@@ -78,7 +76,7 @@ let timerId: number
78
76
const checkAnimateState = () => {
79
77
clearTimeout (timerId )
80
78
timerId = window .setTimeout (() => {
81
- // console.log('check');
79
+ // console.log('check')
82
80
finished .value = countUp .value ?.frameVal == props .endVal
83
81
if (! finished .value ) {
84
82
checkAnimateState ()
@@ -88,12 +86,13 @@ const checkAnimateState = () => {
88
86
watch (finished , (flag ) => {
89
87
if (! flag ) return
90
88
// console.log('finished', flag)
89
+ // console.log('loop', loopCount)
91
90
emits (' finished' )
92
91
const isBool = typeof props .loop === ' boolean'
93
- if (props .loop ) {
94
- if ( isBool || props . loop > loopCount ) {
95
- loopAnim ()
96
- }
92
+ if (( isBool && props .loop ) || props . loop > loopCount ) {
93
+ loopAnim ()
94
+ } else {
95
+ loopCount = 1
97
96
}
98
97
})
99
98
You can’t perform that action at this time.
0 commit comments