2

I'm trying to get the initial position of the app at x:(device.width*2) since the app consist of 3 main views, yet it doesn't seem to move even with the animation delay, it start on the left view.

componentDidMount() {
      const offset = window.width * this.props.initialIndex;
        InteractionManager.runAfterInteractions(() => {
        this._scrollView.scrollTo({x:offset, animated: false});
      })
}
  • This should work, and InteractionManager isn't needed. What version of React Native are you using? – jmurzy Oct 23 '16 at 22:19
  • I'm using RN 0.35, but I added the InteractionManager because I read that scrollview has a layout animation and that I had to delay the scroll to after the animation. – Ricardo Alejandre Oct 23 '16 at 23:10

1 Answers1

5

I also tried with Interaction Manager, but i don't know why it doesn't work; setting a timeout worked for me.

setTimeout(() => {
    this.scrollView.scrollTo(cordenates, animated);
}, 0);
Marco Rojas
  • 442
  • 8
  • 18