Skip to content

Instantly share code, notes, and snippets.

@dbismut
Last active April 9, 2018 08:10
Show Gist options
  • Save dbismut/1c30cb7472f16bd9a0eb4a55dd81e64b to your computer and use it in GitHub Desktop.
Save dbismut/1c30cb7472f16bd9a0eb4a55dd81e64b to your computer and use it in GitHub Desktop.
Part 3 - onScroll update to prevent elastic inertia
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