From 681413a2c22940d101977a2f9899895a380ef21b Mon Sep 17 00:00:00 2001 From: Nairi Narinyan Date: Sun, 4 Nov 2018 20:47:31 +0400 Subject: [PATCH] reanimate and return animation to control --- src/AnimatedCircularProgress.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/AnimatedCircularProgress.js b/src/AnimatedCircularProgress.js index cfbbb17..388779a 100644 --- a/src/AnimatedCircularProgress.js +++ b/src/AnimatedCircularProgress.js @@ -28,16 +28,25 @@ export default class AnimatedCircularProgress extends React.PureComponent { } } + reAnimate(prefill, toVal, dur, ease) { + this.setState({ + fillAnimation: new Animated.Value(prefill) + }, () => this.animate(toVal, dur, ease)); + } + animate(toVal, dur, ease) { const toValue = toVal || this.props.fill; const duration = dur || this.props.duration; const easing = ease || this.props.easing; - return Animated.timing(this.state.fillAnimation, { + const anim = Animated.timing(this.state.fillAnimation, { toValue, easing, duration, - }).start(this.props.onAnimationComplete); + }); + anim.start(this.props.onAnimationComplete); + + return anim; } render() {