@HostListener scroll listener


#1

Has anyone had any luck getting the @HostListener for scroll to work?
Currently testing in Ionic4.

I can use:

@HostListener('document:mousewheel'
@HostListener('document:keydown.enter'

but none of the following work for me for scrolling:

@HostListener('document:scroll', ['$event'])
@HostListener('window:scroll', ['$event'])
@HostListener('scroll', ['$event'])

The page is scrollable and I can use (ionScroll)="scrollHandler($event)" successfully, however, I would like to use @HostListener to see if there is a performance increase on devices.


#2

This is working - if I include:
[scrollEvents]="true" to ion-content

@HostListener("ionScroll", [])
onWindowScroll() {
console.log(' WE ARE SCROLLING');
}