Last active
April 9, 2018 08:10
-
-
Save dbismut/1c30cb7472f16bd9a0eb4a55dd81e64b to your computer and use it in GitHub Desktop.
Part 3 - onScroll update to prevent elastic inertia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onScroll = () => { | |
const scrollTop = windowScroll.get('top'); | |
if (scrollTop < 0 && !this.isTransitioningFromDrag) { | |
if (this.isTouching) this.isDragging = true; | |
if (this.isDragging) { | |
if (scrollTop > -DRAG_THRESHOLD) { | |
const dragProgress = Math.min(1, -scrollTop / DRAG_LIMIT); | |
this.setState({ dragProgress }); | |
} else { | |
this.isTransitioningFromDrag = true; | |
this.props.navigateTo('home'); | |
} | |
} | |
return; | |
} | |
this.setState({ dragProgress: 0 }); | |
this.isDragging = false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment