Skip to content

Commit 392a997

Browse files
authored
Merge pull request #2 from ryanhefner/develop
v0.1.1
2 parents 2d4cab5 + c125e03 commit 392a997

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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",

src/index.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff 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
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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

18161816
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"
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

28022802
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"
28052805
dependencies:
28062806
commander "~2.11.0"
28072807
source-map "~0.5.1"

0 commit comments

Comments
 (0)