From c55dc61cf83554b8aa02d459ea86b8ff12af3da3 Mon Sep 17 00:00:00 2001 From: InJung Chung Date: Thu, 22 Nov 2018 16:46:07 +0900 Subject: [PATCH 1/2] Runs the animation when the default progress is given --- withAnimation.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); From 9d89f6a8501b463f103386cdb31fab7e7020e35f Mon Sep 17 00:00:00 2001 From: InJung Chung Date: Tue, 11 Dec 2018 11:55:42 +0900 Subject: [PATCH 2/2] Set progress text properly when given progress value is greater than 0 --- Circle.js | 3 +++ 1 file changed, 3 insertions(+) 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() {