@the-control-group/ui
Advanced tools
Comparing version 1.7.7 to 1.7.8
@@ -149,2 +149,3 @@ /** | ||
name: PropTypes.string.isRequired, | ||
defaultValue: PropTypes.string, | ||
rows: PropTypes.oneOfType([ | ||
@@ -151,0 +152,0 @@ PropTypes.string, |
@@ -34,3 +34,6 @@ /** | ||
pressedKKey: false, | ||
pressedControlKey: false | ||
pressedControlKey: false, | ||
segmentStartTime: '', | ||
currentSegment: null, | ||
percentageForNextSegment: 0 | ||
}; | ||
@@ -61,6 +64,11 @@ | ||
timer() { | ||
const { segmentStartTime, currentSegment, percentage, percentageForNextSegment } = this.state; | ||
this.setState({ | ||
percentage: this.state.percentage + 1 | ||
// Sometimes state doesn't get updated fast enough and it slows down the progress bar. Need to use Date.now() to get the timestamp in milliseconds for accurate timer | ||
percentage: Date.now() >= segmentStartTime + currentSegment.duration | ||
? percentageForNextSegment | ||
: percentage + 1 | ||
}, () => { | ||
if (this.state.percentage >= 100) { | ||
if (percentage >= 100) { | ||
clearInterval(this.interval); | ||
@@ -119,2 +127,8 @@ setTimeout(this.props.onComplete, this.props.completeDelay); | ||
startSegmentBar(segment) { | ||
this.setState({ | ||
segmentStartTime: Date.now(), | ||
percentageForNextSegment: this.state.percentageForNextSegment + segment.percentage, | ||
currentSegment: segment | ||
}); | ||
this.interval = setInterval(this.timer, (segment.duration / segment.percentage)); | ||
@@ -121,0 +135,0 @@ } |
{ | ||
"name": "@the-control-group/ui", | ||
"version": "1.7.7", | ||
"version": "1.7.8", | ||
"description": "UI kit based on ReactJS for TCG projects", | ||
@@ -5,0 +5,0 @@ "main": "lib/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
74960
1544