Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
persist scroll position
  • Loading branch information
c27192 committed Feb 26, 2020
commit 0c2de3623abeacd536fa65b22000da8b6d26db4e
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const IPropTypes = {
navBarOverlapHeight: number,
scrollViewBackgroundColor: string,
}
let scrollPosY = 0

class ParallaxScrollView extends Component {
constructor(props) {
Expand Down Expand Up @@ -183,7 +184,7 @@ class ParallaxScrollView extends Component {

componentDidUpdate(prevProps) {
if (prevProps.resetScroll !== this.props.resetScroll) {
this.getScrollResponder().scrollTo({x: 0, y: 0, animated: false})
this.getScrollResponder().scrollTo({x: 0, y: scrollPosY - 0.5, animated: false})
this.props.resetScrollSuccessfull()
}
}
Expand All @@ -207,7 +208,7 @@ class ParallaxScrollView extends Component {
} else {
onChangeHeaderVisibility(true)
}

scrollPosY = e.nativeEvent.contentOffset.y
prevOnScroll(e)
}

Expand Down