如何用动画值限制动画衰减

时间:2018-06-26 09:47:09

标签: reactjs animation react-native

我想为动画设置最小和最大toValue

this.myAnimated = new Animated.ValueXY() ; 

和PanResponder中的

onPanResponderRelease: (evt, gestureState) => {
      this.myAnimated.flattenOffset();

      Animated.decay(this.myAnimated, {
          deceleration: 0.997,
          velocity: {x: 0, y: gestureState.vy},
      }).start();
}

我希望我能得到

1 个答案:

答案 0 :(得分:0)

这样为我解决了这个问题

this._value = {x: 0, y: 0};

this.myAnimated.addListener((value) => {

    if (value.y < 100 && value.y > 500 )
       Animated.decay(this.state.myAnimated).stop();

    this._value = value
});