components icon indicating copy to clipboard operation
components copied to clipboard

The existence of md-sidenav-layout prevents scrolling events from being fired

Open jhyde opened this issue 10 years ago • 4 comments

  • Do you want to request a feature or report a bug? Bug
  • What is the current behavior? If an app contains a md-sidenav-layout component, scrolling events are not fired.
  • If the current behavior is a bug, please provide steps to reproduce and if possible a minimal demo of the problem

Here is a plunker with a md-sidenav-layout and a link to open the side nav. It also has a host listener and logs the pageYOffset to console. Be sure and scroll the page and see if you get anything in the console. I did not.

http://plnkr.co/edit/MG0JT6s04ooclNZ4Deun?p=preview

Edit the plnkr and remove or comment out the md-sidenav-layout element. Be sure to remove the closing tag as well. Clear the console. Now scroll the window, and you will see pageYOffset being logged to the console.

  • What is the expected behavior? md-sidenav-layout component should not prevent scrolling events from being fired
  • What is the motivation / use case for changing the behavior? Often scrolling events are needed to trigger the display of a fixed header. This is not currently possible if the md-sidenav-layout is used.
  • Which version of Angular and Material, and which browser and OS does this issue affect? @angular2.0.0 RC.1 @angular2-material2.0.0-alpha.4

Did this work in previous versions of Angular / Material? Please also test with the latest stable and snapshot versions.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix)

jhyde avatar May 20 '16 22:05 jhyde

This is expected behaviour. Please note your page isn't scrolling because your content isn't actually large enough to make it scroll. What you're scrolling is the content of the sidenav. If you add content outside of the sidenav itself your body will scroll.

Cheers!

hansl avatar May 23 '16 18:05 hansl

I don't believe this issue should be closed.

I've edited the plnkr to hopefully make this clearer. http://plnkr.co/edit/MG0JT6s04ooclNZ4Deun?p=preview

First, with the app on the right side, scroll the page up and down. You will see the large 0 change. This is logging the pageYOffset value.

Now edit the app.component.html and Uncomment the stuff that is commented out:

<!--<md-sidenav-layout fullscreen>-->

  <!-- <md-sidenav #sidenav mode="push">
    <md-nav-list>
      <h2>side nav here</h2>
    </md-nav-list>
  </md-sidenav>
   -->

and at the bottom uncomment:

<!--</md-sidenav-layout>-->

Now, scroll the page up and down again. Notice the big 0 never changes. It is no longer logging the pageYOffset value.

jhyde avatar May 23 '16 19:05 jhyde

That's because what you're scrolling is the content of the sidenav <md-content>, not the page. If you open the console and run $('md-sidenav-layout').scrollTop you'll see the proper scrolling position.

This is expected behaviour when you have an overflow: scroll on the content. The page isn't scrolling because the layout is taking the whole page, but isn't taller than 100%. Makes sense?

hansl avatar May 24 '16 00:05 hansl

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.