Skip to content

Instantly share code, notes, and snippets.

@emanuer
Last active April 30, 2017 06:02
Show Gist options
  • Save emanuer/8897917e8d5b043dd9285455161ebadc to your computer and use it in GitHub Desktop.
Save emanuer/8897917e8d5b043dd9285455161ebadc to your computer and use it in GitHub Desktop.
Detect if user scrolled to the bottom of an element
<div (scroll)="onScroll($event)">
// Detect scrolling to the bottom of an element in the
//.component.ts file
onScroll(event) {
const tracker = event.target;
const limit = tracker.scrollHeight - tracker.clientHeight;
if (event.target.scrollTop === limit) {
alert('Bottom reached');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment