I'm aware this more has to do with resetScrollToCoords of https://github.com/APSL/react-native-keyboard-aware-scroll-view/issues/82, but having trouble coming up with a solution for this.
I have a long scrolling view, when trying to fill out text inputs, it makes for awful experience when it keeps scrolling back to the top.
Any suggestions on how to get rid of the behavior and just have the scroll stay in place after clicking out of Input?
It looks like resetScrollToCoords can accept y position, so I tried to make it reset to the current position instead of the default going to the top:
handleScroll(event) {
this.setState({ scrollOffsetY: Math.round(event.nativeEvent.contentOffset.y) });
}
<Content
resetScrollToCoords={{ x: 0, y: this.state.scrollOffsetY }}
onScroll={event => this.handleScroll(event)}
>
which does not seem to work for some reason.
Got this to work:
I keep the current scroll position in my state via onScroll. I then access keyboard aware scroll view via refs, and set resetCoords there manually to the current scroll position.
handleScroll(event) {
this.setState({ scrollY: event.nativeEvent.contentOffset.y });
}
render() {
_.set(this.refs, 'Content._scrollview.resetCoords', { x: 0, y: this.state.scrollY });
return (
<Content
ref="Content"
onScroll={event => this.handleScroll(event)}
>
);
}
Thanks for the fix! Closing this.
hey @booboothefool can you elaborate more on how you fixed the issue? I am having this problem and currently using <Content disableKBDismissScroll={true}/> as a workaround. Ideally it would just scroll to the bottom if the scroll position is past a certain point.
Got this to work:
<Content bounces={false}>
I tried with alternative approach which solves my problem.
<Content scrollEnabled={false}/>
This work for me :)
<Content enableAutomaticScroll={false}/>
Another options we can see with this.
https://github.com/APSL/react-native-keyboard-aware-scroll-view
This works for me on IOS:
<Content enableResetScrollToCoords={false}/>
just found this thread, thanks @quartarian that worked for me!
guys, please add this to the NB documentation, would save a lot of headaches.
Most helpful comment
I tried with alternative approach which solves my problem.
<Content scrollEnabled={false}/>