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

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

  •  0
  • Mahdi Bashirpour  · 技术社区  · 6 年前

    this.myAnimated = new Animated.ValueXY() ; 
    

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

    1 回复  |  直到 6 年前
        1
  •  0
  •   Mahdi Bashirpour    6 年前

    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
    });