动画被执行,但立即返回初始状态

时间:2020-09-23 08:42:40

标签: javascript reactjs react-native animation

这是我的代码,我正在调用状态更改。它得到执行,但立即返回其初始状态。在不另行通知之前,我想保持它的位置。

  const spinValue = new Animated.Value(0)
  const widthValueX = new Animated.Value(0)

  const open = () => {
    Animated.spring(widthValueX, {toValue: 2, useNativeDriver: true}).start()
    Animated.spring(spinValue, {toValue: 2, useNativeDriver: true}).start()
  }

  const growX = widthValueX.interpolate({
    inputRange: [0, 1, 2],
    outputRange: [1, 1.5, 1]
  })

  const spinX = spinValue.interpolate({
    inputRange: [0, 1, 2],
    outputRange: ['0deg', '45deg', '90deg']
  })

0 个答案:

没有答案