2

我正在尝试向我的反应原生应用程序添加动画。但是在安卓和IOS上播放不流畅我应该怎么做才能解决这个问题

我已经尝试使用 Animated 组件运行动画。我的 react-native 版本是“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>
        )
    }
}

此代码工作正常,但不流畅且非常滞后

请帮我解决这个问题

4

1 回答 1

4
Animated.spring(this.moveAnimation, {
      toValue: {x:0, y: 0},
      speed: 5,
  useNativeDriver: true, // <-- Add this
    }).start()
于 2019-02-04T18:35:45.207 回答