jeanregisser / react-native-popover

A <Popover /> component for react-native
660 stars 176 forks source link

Custom animation #14

Closed robclouth closed 8 years ago

robclouth commented 8 years ago

Hey, I'm having issues getting the custom animation to work using startCustomAnimation. It seems like to use startCustomAnimation properly you have to use internal methods. Has anyone managed to do this in an elegant way?

Thanks

Edit: I'm using the latest version

jeanregisser commented 8 years ago

Hi @robclouth I really need to document this ;)

Here's an extract that shows how to use a custom fade animation :

fade: new Animated.Value(0),

<Popover
 ...
  backgroundStyle={{opacity: this.state.fade}}
  popoverStyle={{opacity: this.state.fade}}
  contentStyle={{backgroundColor: 'green'}}
  startCustomAnimation={this._startCustomAnimation}
>
  <Text style={styles.popoverText}>Content</Text>
</Popover>

_startCustomAnimation({show, doneCallback}) {
  Animated.timing(this.state.fade, {
    toValue: show ? 1 : 0,
  }).start(doneCallback);
},

Let me know how it works for you.

robclouth commented 8 years ago

Worked a treat thanks!