React native 反应本机,动画负旋转
我使用平移响应器捕捉用户向下或向上的滑动运动,然后旋转一个圆圈: 如果是肯定的:React native 反应本机,动画负旋转,react-native,react-animated,React Native,React Animated,我使用平移响应器捕捉用户向下或向上的滑动运动,然后旋转一个圆圈: 如果是肯定的: Animated.decay(animation, {velocity: fingerVelocity}).start(); 如果没有: Animated.decay(animationNegative, {velocity: fingerVelocity}).start(); 然后我用上面的方法旋转两个不同的圆: const animationStyle = animation.interpolate
Animated.decay(animation, {velocity: fingerVelocity}).start();
如果没有:
Animated.decay(animationNegative, {velocity: fingerVelocity}).start();
然后我用上面的方法旋转两个不同的圆:
const animationStyle = animation.interpolate({
inputRange: [0, 300],
outputRange: ["0deg", "360deg"],
extrapolate: 'identity'
});
const animationNegativeStyle = animationNegative.interpolate({
inputRange: [0, 300],
outputRange: ["0deg", "-360deg"],
extrapolate: 'identity'
});
对于正极
它工作正常,但对于负极,它逆时针旋转350度,然后顺时针旋转
注意:我之所以使用标识
是因为动画类型是衰减
,我不知道当时的值可能是什么,而衰减
动画的速度取决于用户的滑动速度
因此,当我记录这些值时,负值是这样的:
Animated.decay(animationNegative, {velocity: fingerVelocity}).start();
插值
0 -360
1 -359
2 -358
3 -357
....
360 0
361 1
362 2
....
我知道问题是标识
,但如何解决它
使用Animated
api是否可以实现这一点
const animationNegativeStyle = animationNegative.interpolate({
inputRange: [0, 300],
outputRange: ["360deg", "0deg"],
extrapolate: 'identity'
});
我不确定这个解决方案是否有效,但至少你能尝试一下并分享它的结果吗?我非常确定这就是解决方案 您的正常衰变:
Animated.decay(animation, {velocity: fingerVelocity}).start();
现在,值正在增加,这不是您想要的,您希望它们减少
const animationNegative = Animated.multiply(animationNegative, -1);
const animationNegativeStyle = animationNegative.interpolate({
inputRange: [0, 1],
outputRange: ["0deg", "1deg"], // we don't care, we just want the identity to kick in and use the value as is
extrapolate: 'identity'
});
谢谢,但我肯定不会用的。很明显,从360度到0度,方向是正向的。正确,但是当
identity
生效时,实际值将被使用,而实际值始终是正的,因为decayoh该死,简单,我怎么没想到,该死