我的动画组件无法 运行 流畅地响应本机
My Animated component doesn't run smoothly in react native
我正在尝试将动画添加到我的 React 本机应用程序中。
但是在 Android 和 IOS 上播放不流畅
我应该怎么做才能解决这个问题
我已经尝试 运行 使用 Animated 组件制作动画。
我的本机反应版本是“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>
)
}
}
此代码工作正常,但不流畅且非常滞后
请帮我解决这个问题
Animated.spring(this.moveAnimation, {
toValue: {x:0, y: 0},
speed: 5,
useNativeDriver: true, // <-- Add this
}).start()
我正在尝试将动画添加到我的 React 本机应用程序中。 但是在 Android 和 IOS 上播放不流畅 我应该怎么做才能解决这个问题
我已经尝试 运行 使用 Animated 组件制作动画。 我的本机反应版本是“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>
)
}
}
此代码工作正常,但不流畅且非常滞后
请帮我解决这个问题
Animated.spring(this.moveAnimation, {
toValue: {x:0, y: 0},
speed: 5,
useNativeDriver: true, // <-- Add this
}).start()