I need to compare the values of two AnimatedInterpolation objects in react-native. I want to know which AnimatedInterpolation has the smallest decimal value.
Interpolation documentation
Unfortunately, Math.min(value1, value2) doesn't work.
How can I get the float value of an AnimatedInterpolation object ?
I have tried the following :
interpolateOpacity = () => {
let xOpacity = this.state.pan.x.interpolate({
inputRange: this.props.inputOpacityRangeX,
outputRange: this.props.outputOpacityRangeX
});
let yOpacity = this.state.pan.y.interpolate({
inputRange: this.props.inputOpacityRangeY,
outputRange: this.props.outputOpacityRangeY
});
return Math.min(xOpacity, yOpacity) // NOT WORKING
};
Debugger:

The way I would do this would be to compare the input values.
If your mapping for the output range isn't significantly complicated, you should be able to compare the input ranges like this by accessing this.state.pan.x._value and this.state.pan.y._value, or better practice would be to set up a listener as described here.
I don't think there is a way to compare the interpolated values in real-time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With