Ricardo Alejandre Ricardo Alejandre - 1 year ago 440
Android Question

React-Native .scrollTo with InteractionManager not working

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});

Answer Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download