diff --git a/Circle.js b/Circle.js index 107c4b8..6acc577 100644 --- a/Circle.js +++ b/Circle.js @@ -59,6 +59,9 @@ export class ProgressCircle extends Component { super(props, context); this.progressValue = 0; + if (props.animated) { + this.progressValue = props.progress._value; + } } componentWillMount() { diff --git a/withAnimation.js b/withAnimation.js index 253d063..c705069 100644 --- a/withAnimation.js +++ b/withAnimation.js @@ -24,7 +24,7 @@ export default function withAnimation(WrappedComponent, indeterminateProgress) { constructor(props) { super(props); - this.progressValue = Math.min(Math.max(props.progress, 0), 1); + this.progressValue = 0; this.rotationValue = 0; this.state = { progress: new Animated.Value(this.progressValue), @@ -33,6 +33,7 @@ export default function withAnimation(WrappedComponent, indeterminateProgress) { } componentDidMount() { + this.updateProgress(this.props); this.state.progress.addListener(event => { this.progressValue = event.value; }); @@ -68,6 +69,10 @@ export default function withAnimation(WrappedComponent, indeterminateProgress) { }); } } + this.updateProgress(props) + } + + updateProgress(props) { const progress = props.indeterminate ? indeterminateProgress || 0 : Math.min(Math.max(props.progress, 0), 1);