Skip to content

Instantly share code, notes, and snippets.

@yurikilian
Created January 31, 2020 14:56
Show Gist options
  • Save yurikilian/5041e828b8b258ac55e3856af1b490b6 to your computer and use it in GitHub Desktop.
Save yurikilian/5041e828b8b258ac55e3856af1b490b6 to your computer and use it in GitHub Desktop.
Detect bottom of window scroll event
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