How can I interpolate an Animated value to output to boolean or string in native-native?

I have an animation that goes from -1 to 1 and I want to translate those values ​​into the following two lines:

Previous if the value is negative.

"Next" if the value is positive.

this.state.anim.interpolate({
    inputRange: [-1, 0, 1],
    outputRange: ['Previous','', 'Next'],
})

      

Q: How can I use the value it this.state.anim

contains to decide if we go to the next screen or the previous one.

Additional Information:

this.state.anim

gets values ​​from PanGesture

, and I use this.state.anim

for a lot of other things, so it would be a shame not to use it here too.

+3


source to share





All Articles