I use @HostListener('window:scroll', [])Angular 4 in an application to add an extra class to the title when scrolling. It works fine in Chrome, but I noticed that in Firefox 54.0 (I think this is the latest current version) the class is not added, it does not execute the onWindowScroll () method at all. What could be the reason?
Here is a piece of code and a Plunker demo (which, by the way, also works fine in Chrome, but not in Mozilla):
public isScrolled = false;
constructor(@Inject(DOCUMENT) private document: any) {}
@HostListener('window:scroll', [])
onWindowScroll() {
const number = this.document.body.scrollTop;
if (number > 150) {
this.isScrolled = true;
} else if (this.isScrolled && number < 10) {
this.isScrolled = false;
}
}
Any help is appreciated.
Julsy source
share