Reactjs 反应本机panResponder动画
我有一个lottie组件,当你每次滑动屏幕时,它应该以一个新的动画值运行。现在,从左向右滑动时,将动画值增加到0.3,如果反向滑动,则将动画值减少到0 我想做的是,当你再次滑动屏幕时,值应该变成0.6。第三次刷0.9 你能告诉我怎么做吗Reactjs 反应本机panResponder动画,reactjs,react-native,animation,react-animated,Reactjs,React Native,Animation,React Animated,我有一个lottie组件,当你每次滑动屏幕时,它应该以一个新的动画值运行。现在,从左向右滑动时,将动画值增加到0.3,如果反向滑动,则将动画值减少到0 我想做的是,当你再次滑动屏幕时,值应该变成0.6。第三次刷0.9 你能告诉我怎么做吗 onPanResponderMove: (evt, gesture) => { const { dx } = gesture; if (dx > 30) { Animated.timing(this.state.scrollX, {
onPanResponderMove: (evt, gesture) => {
const { dx } = gesture;
if (dx > 30) {
Animated.timing(this.state.scrollX, {
toValue: 0.3,
duration: 500,
}).start();
} else {
Animated.timing(this.state.scrollX, {
toValue: 0,
}).start();
}
}
render(){
return(
<View>
<LottieView
style={styles.lottie}
source={require('../../assets/lottie/auth_animation.json')}
progress={this.state.scrollX}
/>
</View>
)
}
onPanResponderMove:(evt,手势)=>{
const{dx}=手势;
如果(dx>30){
动画。计时(this.state.scrollX{
toValue:0.3,
持续时间:500,
}).start();
}否则{
动画。计时(this.state.scrollX{
toValue:0,
}).start();
}
}
render(){
返回(
)
}
在onPanResponderMove函数外部存储toValue的值。每次刷卡时,在下次刷卡时增加0.3
toValue = 0;
onPanResponderMove: (evt, gesture) => {
const { dx } = gesture;
if (dx > 30) {
toValue += 0.3;
Animated.timing(this.state.scrollX, {
toValue,
duration: 500,
}).start();
} else {
Animated.timing(this.state.scrollX, {
toValue: 0,
}).start();
}
}
在onPanResponderMove函数外部存储toValue的值。每次刷卡时,在下次刷卡时增加0.3
toValue = 0;
onPanResponderMove: (evt, gesture) => {
const { dx } = gesture;
if (dx > 30) {
toValue += 0.3;
Animated.timing(this.state.scrollX, {
toValue,
duration: 500,
}).start();
} else {
Animated.timing(this.state.scrollX, {
toValue: 0,
}).start();
}
}
你能给我举个例子吗?为你增加了一个例子是的,但问题是我还需要一个善良的状态,这里的值是0.6。所以第一次触摸值从0移动到0.3,第二次触摸值从0.3到0.6,最后是0.6到0.9。我不知道该怎么做((非常感谢任何帮助。你能给我举个例子吗?为你增加了一个例子是的,但问题是我需要一个更友好的状态,其中值为0.6。所以第一次触摸值从0移动到0.3,然后第二次触摸值变为0.3-0.6,最后是0.6-0.9。我不知道该怎么做(((非常感谢您的帮助。