Created
January 31, 2020 14:56
-
-
Save yurikilian/5041e828b8b258ac55e3856af1b490b6 to your computer and use it in GitHub Desktop.
Detect bottom of window scroll event
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
componentDidMount() { | |
this.props.fetch({ ...this.props.searchForm }, 0); | |
window.addEventListener('scroll', (event: any) => this.handleScroll(event)); | |
} | |
componentWillUnmount() { | |
window.removeEventListener('scroll', this.handleScroll); | |
} | |
handleScroll(event: any) { | |
let bottomOfWindow = document.documentElement.scrollTop | |
+ window.innerHeight === document.documentElement.offsetHeight; | |
if (bottomOfWindow) { | |
this.fetchMoreData(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment