Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make React Native Animated.View clickable?

I'm using this react native tinder demo -> https://github.com/brentvatne/react-native-animated-demo-tinder

Is it possible to make the cards 'clickable' so it would navigate to another view on click? I've tried wrapping the "Touchable" components around the animated view but doing so disables the animations.

Any ideas would be highly appreciated, thanks!

like image 770
Denny Avatar asked Sep 23 '15 11:09

Denny


People also ask

What is interpolate React Native?

Interpolation is a way of estimating a function at intermediate points, learning from the ranges you provide. In React Native, you can interpolate animated values using . interpolate which takes an inputRange, that interpolates and maps the values to an outputRange.


1 Answers

Another method (which worked better for me) is to create AnimatedTouchable component using createAnimatedComponent method of Animated:

const AnimatedTouchable = Animated.createAnimatedComponent(TouchableOpacity);

<AnimatedTouchable onPress={this.onPress}>
  stuff here
</AnimatedTouchable>
like image 140
Oleg Dater Avatar answered Oct 13 '22 00:10

Oleg Dater