代码之家  ›  专栏  ›  技术社区  ›  Mahdi

我的动画组件在react native中运行不平稳

  •  1
  • Mahdi  · 技术社区  · 6 年前

    但它在Android和IOS上的运行并不顺利 我该怎么解决这个问题

    我已经尝试使用动画组件运行动画。 我的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>
            )
        }
    }
    

    请帮我解决这个问题

    1 回复  |  直到 6 年前
        1
  •  4
  •   Redmen Ishab    6 年前
    Animated.spring(this.moveAnimation, {
          toValue: {x:0, y: 0},
          speed: 5,
      useNativeDriver: true, // <-- Add this
        }).start()