File tree Expand file tree Collapse file tree 3 files changed +23
-24
lines changed Expand file tree Collapse file tree 3 files changed +23
-24
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-timer-wrapper" ,
3
- "version" : " 0.1.0 " ,
3
+ "version" : " 0.1.1 " ,
4
4
"license" : " MIT" ,
5
5
"description" : " Composable React Timer component that passes its status to its children." ,
6
6
"repository" : " ryanhefner/react-timer-wrapper" ,
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
}
Original file line number Diff line number Diff line change @@ -1814,8 +1814,8 @@ js-tokens@^3.0.0:
1814
1814
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
1815
1815
1816
1816
js-yaml@^3.7.0 :
1817
- version "3.9.0 "
1818
- resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.9.0 .tgz#4ffbbf25c2ac963b8299dc74da7e3740de1c18ce "
1817
+ version "3.9.1 "
1818
+ resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.9.1 .tgz#08775cebdfdd359209f0d2acd383c8f86a6904a0 "
1819
1819
dependencies :
1820
1820
argparse "^1.0.7"
1821
1821
esprima "^4.0.0"
@@ -2800,8 +2800,8 @@ uglify-js@^2.6:
2800
2800
uglify-to-browserify "~1.0.0"
2801
2801
2802
2802
uglify-js@^3.0.9 :
2803
- version "3.0.26 "
2804
- resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.0.26 .tgz#ba279ca597b13fe6c62c2d87dd5188e57a7a3233 "
2803
+ version "3.0.27 "
2804
+ resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.0.27 .tgz#a97db8c8ba6b9dba4e2f88d86aa9548fa6320034 "
2805
2805
dependencies :
2806
2806
commander "~2.11.0"
2807
2807
source-map "~0.5.1"
You can’t perform that action at this time.
0 commit comments