Created
January 30, 2017 22:12
-
-
Save danmakenoise/b31bfdcd0164b03813c6fb59342e2956 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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