From a8c5c3574c34eb9331bc331a9d35893263f20dfa Mon Sep 17 00:00:00 2001 From: Behzad Abbasi Date: Fri, 26 Jan 2018 20:19:52 +0330 Subject: [PATCH] working better animation starting animation after change color not working correctly, so, I use a flag for that --- CircleTransition.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CircleTransition.js b/CircleTransition.js index 5809419..885eaad 100644 --- a/CircleTransition.js +++ b/CircleTransition.js @@ -9,19 +9,24 @@ class CircleTransition extends Component { this.state = { scale: new Animated.Value(0), - color: '#ccc' + color: '#ccc', + startedAniation: false }; } start(color, callback) { this.setState({ - color: color + color: color, + startedAniation: true }, () => { this.animate(callback); }); } animate(callback) { + this.setState({ + startedAniation: false + }); Animated.timing(this.state.scale, { toValue: 4, duration: this.props.duration, @@ -87,4 +92,4 @@ CircleTransition.defaultProps = { easing: Easing.linear } -export default CircleTransition; \ No newline at end of file +export default CircleTransition;