【问题标题】:Animated.timing() with negative delay带有负延迟的 Animated.timing()
【发布时间】:2017-01-20 07:02:09
【问题描述】:

我使用 Animated.timing() 在 react-native 中创建了一个动画,我想在其中开始动画。有什么方法可以将负值应用于延迟,例如 css 中的this。我的示例代码如下:

Animated.timing(this.state.animatedVal, {
  toValue: 100,
  duration: 500,
  easing: Easing.inOut(Easing.ease),
  delay: 200,
}).start()

【问题讨论】:

    标签: animation react-native react-animated


    【解决方案1】:

    据我所知,负延迟不是问题...但是,您可以在开始动画之前在动画值上使用 setValue 以获得相同的效果。它实际上取决于您的动画值的用例,因为它可能会导致动画突然跳跃,但由于您无论如何都想在中途启动它,这应该可以例如:

    this.state.animatedVal.setValue(50);
    Animated.timing(this.state.animatedVal, {
      toValue: 100,
      duration: 250, // the portion of the time of the full animation
      easing: Easing.inOut(Easing.ease),
    }).start()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-16
      • 1970-01-01
      • 2016-01-24
      • 2018-12-21
      • 2010-12-03
      • 2021-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多