Is this any way to trigger event when div reach top of the window in Angular? I need to fire animation when client scroll to specific place with id but can't find any solution for this problem.
Asked
Active
Viewed 800 times
0
-
Did you find the answer helpful? – Krzysztof Lach Sep 30 '17 at 17:31
-
@KrzysztofLa unfortunately, no – Bogdan Tushevskyi Oct 03 '17 at 12:36
-
1@krzysztofla with code refactoring your answer is working, thanks – Bogdan Tushevskyi May 29 '18 at 09:16
1 Answers
2
@HostListener('scroll', ['$event'])
onScroll(event) {
this.scroll = event.srcElement.scrollTop
...
}
and your specific div
<div (scroll)="onScroll($event)">
getting the actual scroll position
document.documentElement.scrollTop
Documentation:

Krzysztof Lach
- 1,280
- 1
- 12
- 19