Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stickyThing not working inside a mat-sidenav-content #25

Closed
ciukstar opened this issue Feb 20, 2019 · 10 comments
Closed

stickyThing not working inside a mat-sidenav-content #25

ciukstar opened this issue Feb 20, 2019 · 10 comments
Labels
fixed Issue is fixed / resolved.

Comments

@ciukstar
Copy link

Hi!

It seems that stickyThing is not working "inside" a mat-sidenav-content of a mat-sidenav-container. Is it possible to make it work? How about stickyThing "inside" a mat-sidenav-content of a mat-sidenav-container of a mat-sidenav-content of a mat-sidenav-container?

Thanks!

@CanKattwinkel
Copy link

CanKattwinkel commented Feb 21, 2019

Hey @ciukstar,

thank you for your report! I just gave it a shot in a forked StackBlitz and I can confirm the issue you are describing. I already have a suspicion, Material sets the content component to position:absolute, l0,r0,t0,b0. This leads to the issue with Sticky Things, since the body no longer scrolls, but another target. I'll look into it, but it might take me some days.

Repro:
https://stackblitz.com/edit/dynamic-nested-sidenav-menu-z4xws2?file=app/first/first.component.html

@ciukstar
Copy link
Author

It would be great if stickyThing would work when wrapped in a scrollable mat-sidenav-container.

My concrete scenario is a stickyThing wrapped in a mat-sidenav-content wrapped in a mat-sidenav-container which is wrapped in a scrollable mat-sidenav-content of a mat-sidenav-container.

Thanks a lot!

@sergegl
Copy link

sergegl commented Feb 25, 2019

Hello,

I have a similar issue, I am trying to use stickyThing inside absolute position element.
For example its set to top: 0, right: 0, left: 0, bottom: 0.

Hopefully there is a solution.

Thanks!

@CanKattwinkel
Copy link

Please test with version 1.1.2. You can now specify the scroll container element. Not sure if any usecase is covered, my minimal example currently covers a position absolute element that has a scroll bar:

https://w11k.github.io/angular-sticky-things/posa

In order to specify a scroll container:

<div class="scroll-container">
  <div #spacer></div>
  <div [spacer]="spacer" stickyThing="" scrollContainer=".scroll-container">
    Scroll by!
  </div>
</div>

Use anything that can be evaluated by document.querySelector or pass in a html element.

Waiting for your feedback!

( fyi @kaihenzler )

@sergegl
Copy link

sergegl commented Mar 4, 2019

Please test with version 1.1.2. You can now specify the scroll container element. Not sure if any usecase is covered, my minimal example currently covers a position absolute element that has a scroll bar:

https://w11k.github.io/angular-sticky-things/posa

In order to specify a scroll container:

<div class="scroll-container">
  <div #spacer></div>
  <div [spacer]="spacer" stickyThing="" scrollContainer=".scroll-container">
    Scroll by!
  </div>
</div>

Use anything that can be evaluated by document.querySelector or pass in a html element.

Waiting for your feedback!

( fyi @kaihenzler )

Awesome, I think this should work fine, will test later.
I was about to fork your library, but was busy with other work, so kudos for you for a quick response!

Thank you!

@sergegl
Copy link

sergegl commented Mar 4, 2019

I just tested, and it works, thanks!

Small issue I encountered.
When I bind the value as marginTop=30, it didn't work. I had to use it as [marginTop]=30 instead. it was adding the value as a string concat instead adding two numbers together. So if my object is 100px height it would return a spacer height as 10030px instead of 130px.

Thanks again.

@CanKattwinkel
Copy link

Thanks for the review. Yepp, its a known issue that has already been fixed by another user. Will be released soon! #26

@ciukstar
Copy link
Author

ciukstar commented Mar 5, 2019

Yes it works. Thank you very much!

@anelad
Copy link

anelad commented Sep 29, 2019

I still cannot make it work. Tried everything mentioned in the comments one by one...

@ghost ghost added the fixed Issue is fixed / resolved. label Nov 5, 2019
@getsetbro
Copy link

getsetbro commented Nov 8, 2019

It worked for me when I did it like this:

<mat-sidenav-container>
  <mat-sidenav>…</mat-sidenav>
  <mat-sidenav-content class="msc">
    <div class="content">…</div>
  </mat-sidenav-content>
</mat-sidenav-container>

<div stickyThing [scrollContainer]="'.msc'"></div>

It gets the element there in time for the directive to find it. @anelad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Issue is fixed / resolved.
Projects
None yet
Development

No branches or pull requests

5 participants