angularangular-material2onscroll

OnScroll Event not firing inside a mat-drawer-container


I have a bunch of content inside of a mat-drawer-container and I would like to listen for scroll events on it. I have tried window.onscroll() and it did not work. I removed the mat-drawer-container and window.onscroll() worked. I think the mat-drawer-container is the issue.


Solution

  • It should work if you listen to the scroll event on the mat-drawer-content class.

    document.getElementsByClassName('mat-drawer-content').item(0)!.addEventListener('scroll', () => {
        console.log('It works!')
      })