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

stickyHeaders_attachTo doesn't work in most cases #1633

Open
JohnSmall opened this issue Feb 28, 2019 · 2 comments
Open

stickyHeaders_attachTo doesn't work in most cases #1633

JohnSmall opened this issue Feb 28, 2019 · 2 comments

Comments

@JohnSmall
Copy link

There's clearly a special undocumented rule about using stickyHeaders_attachTo because it only works in some cases. Mostly it doesn't work at all.

Example, Mottie's JS Fiddle example , works as is, but if you make any tiny change, it stops working. E.g. I tried stickyHeaders_attachTo: '.modal-content' but that doesn't work.

So I tried giving the .modal-content div an id and used that. Still doesn't work.

So there must be a special rule about which element stickyHeaders_attachTo: can actually attach to. But it's not documented anywhere.

I guessed it might be that stickyHeaders_attachTo: can only attach to fixed divs. But when I tried that in the JSFiddle it made no difference. stickyHeaders_attachTo: only works if it's set to '#myModal' the outer div. Anything else fails.

Which actually looks terrible, because the padding in BS modals means that the table inside .modal-content is offset from the headings attached to #myModal, it jumps when it sticks, and you can still see the headings scroll out of view underneath.

Does anyone know the secret of which divs stickyHeaders_attachTo: is allowed to attach to?

@JohnSmall
Copy link
Author

Hunting around for similar issues I found this #1371 But...

The solution in https://jsfiddle.net/Mottie/z8Lacguz/36/ is not to use the stickyHeaders widget at all, but to use cssStickyHeaders, set cssStickyHeaders_attachTo: null and use cssStickyHeaders_offset: $('.navbar').height() which implies that cssStickyHeaders_attachTo is a completely useless option.

So now I'm confused. Should I be using stickyHeaders or cssStickyHeaders? Should I ignore cssStickyHeaders_attachTo and just use the offset?

@Mottie
Copy link
Owner

Mottie commented Feb 28, 2019

Hi @JohnSmall!

I believe the issue is that the element that is targeted by attachTo must be the element that scrolls. In the demo, it's #myModal. In issue #1512, it's a div with a .body class. When the attachTo targets an element within the scrolling element, it doesn't provide an appropriate scrollTop value (it'll always be zero).

The offset is meant to add extra space above the sticky header in case you already have an unrelated sticky header above it.

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

No branches or pull requests

2 participants