react-countdown
Advanced tools
Comparing version 2.3.3 to 2.3.4
@@ -6,3 +6,3 @@ import * as React from 'react'; | ||
export interface CountdownProps extends React.Props<Countdown>, CountdownTimeDeltaFormatOptions, Omit<LegacyCountdownProps, 'onComplete'> { | ||
readonly date?: Date | number | string; | ||
readonly date: Date | number | string; | ||
readonly controlled?: boolean; | ||
@@ -22,3 +22,3 @@ readonly intervalDelay?: number; | ||
readonly onTick?: CountdownTimeDeltaFn; | ||
readonly onComplete?: CountdownTimeDeltaFn | LegacyCountdownProps['onComplete']; | ||
readonly onComplete?: (timeDelta: CountdownTimeDelta, completedOnStart: boolean) => void | LegacyCountdownProps['onComplete']; | ||
} | ||
@@ -99,3 +99,2 @@ export interface CountdownRenderProps extends CountdownTimeDelta { | ||
isStatus(status: CountdownStatus): boolean; | ||
handleOnComplete: (timeDelta: CountdownTimeDelta) => void; | ||
setTimeDeltaState(timeDelta: CountdownTimeDelta, status?: CountdownStatus, callback?: (timeDelta: CountdownTimeDelta) => void): void; | ||
@@ -102,0 +101,0 @@ getApi(): CountdownApi; |
@@ -372,6 +372,2 @@ import { cloneElement, Component, createRef, createElement } from 'react'; | ||
_this.handleOnComplete = function (timeDelta) { | ||
if (_this.props.onComplete) _this.props.onComplete(timeDelta); | ||
}; | ||
if (props.date) { | ||
@@ -469,7 +465,7 @@ var timeDelta = _this.calcTimeDelta(); | ||
if (!this.mounted) return; | ||
var completedCallback; | ||
var completing = timeDelta.completed && !this.state.timeDelta.completed; | ||
var completedOnStart = timeDelta.completed && status === "STARTED"; | ||
if (!this.state.timeDelta.completed && timeDelta.completed) { | ||
if (!this.props.overtime) this.clearTimer(); | ||
completedCallback = this.handleOnComplete; | ||
if (completing && !this.props.overtime) { | ||
this.clearTimer(); | ||
} | ||
@@ -479,3 +475,6 @@ | ||
if (callback) callback(_this2.state.timeDelta); | ||
if (completedCallback) completedCallback(_this2.state.timeDelta); | ||
if (_this2.props.onComplete && (completing || completedOnStart)) { | ||
_this2.props.onComplete(timeDelta, completedOnStart); | ||
} | ||
}; | ||
@@ -482,0 +481,0 @@ |
@@ -376,6 +376,2 @@ 'use strict'; | ||
_this.handleOnComplete = function (timeDelta) { | ||
if (_this.props.onComplete) _this.props.onComplete(timeDelta); | ||
}; | ||
if (props.date) { | ||
@@ -473,7 +469,7 @@ var timeDelta = _this.calcTimeDelta(); | ||
if (!this.mounted) return; | ||
var completedCallback; | ||
var completing = timeDelta.completed && !this.state.timeDelta.completed; | ||
var completedOnStart = timeDelta.completed && status === "STARTED"; | ||
if (!this.state.timeDelta.completed && timeDelta.completed) { | ||
if (!this.props.overtime) this.clearTimer(); | ||
completedCallback = this.handleOnComplete; | ||
if (completing && !this.props.overtime) { | ||
this.clearTimer(); | ||
} | ||
@@ -483,3 +479,6 @@ | ||
if (callback) callback(_this2.state.timeDelta); | ||
if (completedCallback) completedCallback(_this2.state.timeDelta); | ||
if (_this2.props.onComplete && (completing || completedOnStart)) { | ||
_this2.props.onComplete(timeDelta, completedOnStart); | ||
} | ||
}; | ||
@@ -486,0 +485,0 @@ |
{ | ||
"name": "react-countdown", | ||
"version": "2.3.3", | ||
"version": "2.3.4", | ||
"description": "A customizable countdown component for React.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64854
1181