Last active
April 9, 2018 08:11
-
-
Save dbismut/a31c7cb81e15cac4ae127a5cdb734d07 to your computer and use it in GitHub Desktop.
Part 3 - Creates onScroll method and related state to prepare for the drag feature
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
class Post extends PureComponent { | |
state = { | |
dragProgress: 0 | |
} | |
/* ... */ | |
onScroll = () => { | |
const scrollTop = windowScroll.get('top'); | |
if (scrollTop < 0 && !this.isTransitioningFromDrag) { | |
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 }); | |
}; | |
/* ... */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment