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 11{
22 "name" : " react-timer-wrapper" ,
3- "version" : " 0.1.0 " ,
3+ "version" : " 0.1.1 " ,
44 "license" : " MIT" ,
55 "description" : " Composable React Timer component that passes its status to its children." ,
66 "repository" : " ryanhefner/react-timer-wrapper" ,
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ class TimerWrapper extends Component {
4141
4242 switch ( active ) {
4343 case true :
44- const nextTime = duration !== null && this . state . time == = duration
44+ const nextTime = duration !== null && this . state . time > = duration
4545 ? 0
4646 : this . state . time ;
4747
@@ -107,34 +107,33 @@ class TimerWrapper extends Component {
107107 time : nextTime ,
108108 } ) ;
109109
110- if ( duration !== null && progress === 1 ) {
110+ this . setState ( {
111+ time : nextTime ,
112+ } ) ;
113+
114+ if ( duration !== null && this . state . time >= duration ) {
111115 onFinish ( {
112116 duration,
113117 progress,
114118 time : nextTime ,
115119 } ) ;
116120
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 ) {
130122 cancelAnimationFrame ( this . animationFrame ) ;
131123 return ;
132124 }
133- }
134125
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+ }
138137
139138 this . animationFrame = requestAnimationFrame ( this . tick ) ;
140139 }
Original file line number Diff line number Diff line change @@ -1814,8 +1814,8 @@ js-tokens@^3.0.0:
18141814 resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
18151815
18161816js-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 "
18191819 dependencies :
18201820 argparse "^1.0.7"
18211821 esprima "^4.0.0"
@@ -2800,8 +2800,8 @@ uglify-js@^2.6:
28002800 uglify-to-browserify "~1.0.0"
28012801
28022802uglify-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 "
28052805 dependencies :
28062806 commander "~2.11.0"
28072807 source-map "~0.5.1"
You can’t perform that action at this time.
0 commit comments