【问题标题】:Move Xposition of View from 0 to its origianl position in React Native将 View 的 X 位置从 0 移动到 React Native 中的原始位置
【发布时间】:2020-06-09 06:56:32
【问题描述】:
const valueX = useRef(new Animated.Value(0)).current

  useEffect(() => {
    Animated.timing( valueX , {
      toValue  :  // How to get the original X position of the component here.
      duration : 1000,
      easing  : Easing.linear
    }).start()
  }, [])

所以,我最初在屏幕上的某个位置有一个组件(即视图)。我想在那里使用反应原生动画 API 制作一个轻微的动画。我想要的是 将该视图的 X 位置从 0 移动到其原始位置 。如何做呢?

【问题讨论】:

    标签: react-native use-effect react-animated react-animations


    【解决方案1】:

    我猜您需要元素的位置 - 将其设置为您的状态,然后以您想要的方式更改它。查看此问题以获取元素位置。

    React Native: Getting the position of an element

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-24
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多