0
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()
  }, [])

So, I have a component (i.e View) originally at some position on the screen. I wanted to have a slight animation there using react native animated API. What I want is to move X position of that view from 0 to its original position . How can it be done?

1 Answers1

0

I guess you need the position of the element - set that as your state and then change it in the way you want. Check out this question to get the elements position.

React Native: Getting the position of an element

yesIamFaded
  • 1,970
  • 2
  • 20
  • 45