Reactjs 我的动画组件没有';我在家里跑得不顺
我正在尝试将动画添加到我的react本机应用程序中。 但它在Android和IOS上的运行并不顺利 我该怎么解决这个问题Reactjs 我的动画组件没有';我在家里跑得不顺,reactjs,react-native,react-native-animatable,Reactjs,React Native,React Native Animatable,我正在尝试将动画添加到我的react本机应用程序中。 但它在Android和IOS上的运行并不顺利 我该怎么解决这个问题 Animated.spring(this.moveAnimation, { toValue: {x:0, y: 0}, speed: 5, useNativeDriver: true, // <-- Add this }).start() 我已经尝试使用动画组件运行动画。 我的react本机版本是“0.57.8” 这是我的代码: e
Animated.spring(this.moveAnimation, {
toValue: {x:0, y: 0},
speed: 5,
useNativeDriver: true, // <-- Add this
}).start()
我已经尝试使用动画组件运行动画。
我的react本机版本是“0.57.8”
这是我的代码:
export default class MainPage extends Component{
constructor(props) {
super(props)
this.moveAnimation = new Animated.ValueXY({ x: 0, y: 0})
}
_openCardContainer = () => {
Animated.spring(this.moveAnimation, {
toValue: {x:0, y: 0},
speed: 5,
}).start()
}
render() {
return(
<Animated.View style={this.moveAnimation.getLayout()}>
<EditorChoiceContainer/>
</Animated.View>
)
}
}
导出默认类主页扩展组件{
建造师(道具){
超级(道具)
this.moveAnimation=new Animated.ValueXY({x:0,y:0})
}
_openCardContainer=()=>{
动画.spring(this.moveAnimation{
toValue:{x:0,y:0},
速度:5,,
}).start()
}
render(){
返回(
)
}
}
这段代码工作正常,但并不流畅,而且非常滞后
请帮我解决这个问题Animated.spring(this.moveAnimation{
Animated.spring(this.moveAnimation, {
toValue: {x:0, y: 0},
speed: 5,
useNativeDriver: true, // <-- Add this
}).start()
toValue:{x:0,y:0},
速度:5,,
useNativeDriver:true,//我以前尝试过这种方法,但我遇到了以下错误:未处理的JS异常:错误:本机动画模块不支持样式属性“left”
嘿,对于慢速动画的问题,解决方案是使用本机驱动程序。对于出现的错误,使用translateX和translate进行修复Y而不是左上方。希望它有助于在开发模式下运行应用程序可能会影响性能,请尝试在发布模式下运行应用程序(react native run ios--configuration Release)。