Skip to content

Instantly share code, notes, and snippets.

@dbismut
Created April 9, 2018 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbismut/eb6133f09a7bf0be08327149c1d2a671 to your computer and use it in GitHub Desktop.
Save dbismut/eb6133f09a7bf0be08327149c1d2a671 to your computer and use it in GitHub Desktop.
Part 3 - Modifying the onScroll method for handling the closeInvert state
state = {
dragProgress: 0,
closeInverted: false,
};
onScroll = () => {
/* same code */
// handling close icon color
const threshold = scrollTop / CLOSE_INVERTED_THRESHOLD;
if (!this.state.closeInverted && threshold > window.innerHeight - 54) {
this.setState({ closeInverted: true });
} else if (
this.state.closeInverted &&
threshold <= window.innerHeight - 54
) {
this.setState({ closeInverted: false });
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment