Merge pull request #20 from slaweet/patch-1

Keep progress bar within 0 and 100
This commit is contained in:
Kevin Qi 2017-08-27 17:47:29 -07:00 committed by GitHub
commit 8baa206378

View File

@ -44,7 +44,7 @@ class CircularProgressbar extends React.Component {
const diameter = Math.PI * 2 * radius;
const progressStyle = {
strokeDasharray: `${diameter}px ${diameter}px`,
strokeDashoffset: `${((100 - this.state.percentage) / 100 * diameter)}px`,
strokeDashoffset: `${((100 - Math.min(Math.max(this.state.percentage, 0), 100)) / 100 * diameter)}px`,
};
const classForPercentage = this.props.classForPercentage ? this.props.classForPercentage(this.props.percentage) : '';