Skip to content

Commit

Permalink
v2.1.2 (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndresx authored Nov 4, 2019
2 parents ed15233 + 00ce02f commit 7edc709
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@types/react": "^16.8.15",
"@types/react-dom": "16.8.4",
"react": "^16.8.6",
"react-countdown-now": "^2.1.1",
"react-countdown-now": "^2.1.2",
"react-dom": "^16.8.6",
"react-scripts": "3.0.0",
"typescript": "3.4.5"
Expand Down
8 changes: 4 additions & 4 deletions examples/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7871,10 +7871,10 @@ react-app-polyfill@^1.0.0:
regenerator-runtime "0.13.2"
whatwg-fetch "3.0.0"

react-countdown-now@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/react-countdown-now/-/react-countdown-now-2.1.1.tgz#88901eb776907338da137effbf7cdbec5b9274c6"
integrity sha512-DGSd/EGzigIsixQNzPQbk376zG49IVAyMCUkMgDEuIXlIRKQwB44Fg8uA3zrZ+aQVAuzsyb6fJWskPxIP56DYg==
react-countdown-now@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/react-countdown-now/-/react-countdown-now-2.1.2.tgz#b93d153fbb7a8d359beb32ecbf1de29d15f026c7"
integrity sha512-BgRnsxV2vnvyJAefDBigTX+ngX6eGd2xl6DIFdZPIZkbx0mzxlMEeoEQG01JyeHDjqaXFUpIonIbx1yYyaMwzg==
dependencies:
lodash.isequal "^4.5.0"
prop-types "^15.7.2"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-countdown-now",
"version": "2.1.1",
"version": "2.1.2",
"description": "A customizable countdown component for React.",
"main": "./dist/index.js",
"module": "./dist/index.es.js",
Expand Down
22 changes: 12 additions & 10 deletions src/Countdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ export default class Countdown extends React.Component<CountdownProps, Countdown

tick = (): void => {
const { onTick } = this.props;
const delta = this.calcTimeDelta();
const timeDelta = this.calcTimeDelta();

this.setTimeDeltaState({ ...delta });
this.setTimeDeltaState({ ...timeDelta });

if (onTick && delta.total > 0) {
onTick(delta);
if (onTick && timeDelta.total > 0) {
onTick(timeDelta);
}
};

Expand Down Expand Up @@ -160,9 +160,11 @@ export default class Countdown extends React.Component<CountdownProps, Countdown
};

pause = (): void => {
this.clearInterval();
this.setState({ offsetStart: this.calcOffsetStart() }, () => {
this.clearInterval();
this.props.onPause && this.props.onPause(this.calcTimeDelta());
const timeDelta = this.calcTimeDelta();
this.setTimeDeltaState(timeDelta);
this.props.onPause && this.props.onPause(timeDelta);
});
};

Expand All @@ -178,17 +180,17 @@ export default class Countdown extends React.Component<CountdownProps, Countdown
return this.state.timeDelta.completed;
};

setTimeDeltaState(delta: CountdownTimeDelta): void {
setTimeDeltaState(timeDelta: CountdownTimeDelta): void {
let callback;

if (!this.state.timeDelta.completed && delta.completed) {
if (!this.state.timeDelta.completed && timeDelta.completed) {
this.clearInterval();

callback = () => this.props.onComplete && this.props.onComplete(delta);
callback = () => this.props.onComplete && this.props.onComplete(timeDelta);
}

if (this.mounted) {
return this.setState({ timeDelta: delta }, callback);
return this.setState({ timeDelta }, callback);
}
}

Expand Down

0 comments on commit 7edc709

Please sign in to comment.