File tree 1 file changed +18
-19
lines changed
1 file changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ class TimerWrapper extends Component {
41
41
42
42
switch ( active ) {
43
43
case true :
44
- const nextTime = duration !== null && this . state . time == = duration
44
+ const nextTime = duration !== null && this . state . time > = duration
45
45
? 0
46
46
: this . state . time ;
47
47
@@ -107,34 +107,33 @@ class TimerWrapper extends Component {
107
107
time : nextTime ,
108
108
} ) ;
109
109
110
- if ( duration !== null && progress === 1 ) {
110
+ this . setState ( {
111
+ time : nextTime ,
112
+ } ) ;
113
+
114
+ if ( duration !== null && this . state . time >= duration ) {
111
115
onFinish ( {
112
116
duration,
113
117
progress,
114
118
time : nextTime ,
115
119
} ) ;
116
120
117
- if ( loop ) {
118
- nextTime = 0 ;
119
- onStart ( {
120
- duration,
121
- progress : 0 ,
122
- time : nextTime ,
123
- } ) ;
124
-
125
- this . setState ( {
126
- startTime : Date . now ( ) ,
127
- } ) ;
128
- }
129
- else {
121
+ if ( ! loop ) {
130
122
cancelAnimationFrame ( this . animationFrame ) ;
131
123
return ;
132
124
}
133
- }
134
125
135
- this . setState ( {
136
- time : nextTime ,
137
- } ) ;
126
+ nextTime = 0 ;
127
+ onStart ( {
128
+ duration,
129
+ progress : 0 ,
130
+ time : nextTime ,
131
+ } ) ;
132
+
133
+ this . setState ( {
134
+ startTime : Date . now ( ) ,
135
+ } ) ;
136
+ }
138
137
139
138
this . animationFrame = requestAnimationFrame ( this . tick ) ;
140
139
}
You can’t perform that action at this time.
0 commit comments