Búsqueda de sitios web

angular - El seguimiento del desplazamiento no funciona con Internet Explorer 11


Tengo el siguiente código:

this.currentScrollYSub = Observable.fromEvent(window, 'scroll')
    .throttleTime(5)
    .subscribe(e => {
    this.scrollY = window.scrollY;
    console.log(window.scrollY); // Result: undefined
    });

Que funciona perfectamente en Chrome, pero noté que en IE 10 e IE 11, no funciona.

¿Cómo puedo hacer que esto funcione en Internet Explorer 11?

EDITAR

También probé algo así:

@HostListener('window:scroll', ['$event'])
track(event) {
    console.debug("Scroll Event ", document.body.scrollTop); // Result: "Scroll Event 0"
}

@HostListener('window:scroll', ['$event'])
track(event) {
    console.debug("Scroll Event ", this.scrollY); // Result: "Scroll Event undefined"
}

Respuesta #1

https://developer.mozilla.org/es/docs/Web/API/Window/scrollY

Internet Explorer: Sin soporte

Puedes usar algo como:

return {
  x: window.pageXOffset || document.documentElement.scrollLeft,
  y: window.pageYOffset || document.documentElement.scrollTop
};

https://github.com/ReactTraining/react-router/issues/605