Reputation: 177
I have a sequenced animation started by button A, how can I stop the animation by button B?thank you
Upvotes: 0
Views: 2323
Reputation: 32392
Store your animation in a state variable and call start
or stop
when you click a button:
constructor() {
super(props);
var my_animation = ... // define your animation here
this.state = {
my_animation: my_animation;
}
}
startAnimation() {
this.state.my_animation.start();
}
stopAnimation() {
this.state.my_animation.stop();
}
render() {
<Button onPress={() => this.startAnimation()} />
<Button onPress={() => this.stopAnimation()} />
}
For more info on start
and stop
see https://facebook.github.io/react-native/docs/animations.html
Upvotes: 1