Skip to content

Instantly share code, notes, and snippets.

@danmakenoise
Created January 30, 2017 22:12
Show Gist options
  • Save danmakenoise/b31bfdcd0164b03813c6fb59342e2956 to your computer and use it in GitHub Desktop.
Save danmakenoise/b31bfdcd0164b03813c6fb59342e2956 to your computer and use it in GitHub Desktop.
class Component extends React.Component {
constructor(props) {
super(props);
this.initialState = {
isBelowScrollLine: false
};
this.scrollListener = this.scrollListener.bind(this);
}
componentDidMount() {
window.requestAnimationFrame(this.scrollListener);
}
scrollListener() {
const isBelowScrollLine = // logic to determine if we are passed the point you want.
if (isBelowScrollLine && !this.state.isBelowScrollLine) {
this.setState({ isBelowScrollLine: true });
} else if (!isBelowScrollLine && this.state.isBelowScrollLine) {
component.setState({ isBelowScrollLine: false });
}
window.requestAnimationFrame(this.scrollListener);
}
render() {
// some pretty crap
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment