0

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.

Lazar Ljubenović
  • 18,976
  • 10
  • 56
  • 91
Bogdan Tushevskyi
  • 712
  • 2
  • 12
  • 25

1 Answers1

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