react-native-animatable icon indicating copy to clipboard operation
react-native-animatable copied to clipboard

How can I initialize render without animation starts

Open paulobatista-dev opened this issue 9 years ago • 2 comments

Hi! I have a doubt, is there a way to initialize my render method without start the animation? In my case, i have a menu icon inside a toolbar. This icon should rotate only the user touches it, But when this screen's rendered the icon rotate. How can i rotate the menu icon only the user interact with it? I Know about startAnimation() and stopAnimation() methods and i tried put the animation in state, but without success yet.

My App is for both platforms - Android and IOs Thanks! and pardon about my bad English.

paulobatista-dev avatar Jun 20 '17 23:06 paulobatista-dev

I'm in the same boat here, also looking for a good way to execute animation on a component (that might use 'ref' , the refs things in React)

jpaulin avatar Aug 09 '17 08:08 jpaulin

Define your Animatable without the duration and animation props (you can still use others like easing), set a reference to it and trigger the animation programmatically with the animation and duration of your choice.

Example:

render() {
  return (
    <TouchableWithoutFeedback onPress={() => this.onPress()}>
      <Animatable.View ref={ref => { this.animatable = ref }}>
        <YourComponentHere />
      </Animatable.View>
    </TouchableWithoutFeedback>
  );
}

Then in onPress():

onPress() {
  this.animatable.rotate(800);
}

inanc-g avatar Oct 04 '17 02:10 inanc-g