Last active
April 30, 2017 06:02
-
-
Save emanuer/8897917e8d5b043dd9285455161ebadc to your computer and use it in GitHub Desktop.
Detect if user scrolled to the bottom of an element
This file contains 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
<div (scroll)="onScroll($event)"> |
This file contains 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
// 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