Javascript 动画得到执行,但随后立即返回到初始状态

Javascript 动画得到执行,但随后立即返回到初始状态,javascript,reactjs,react-native,animation,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()

这是我的密码,我打电话是想改变一下状态。它被执行,但随后立即返回到初始状态。我想让它保持它的位置,直到我告诉它

  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']
  })

你的状态改变功能在哪里。你能分享吗?@MohammadFaisal我只是用open()调用动画,就是这样