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

Doesn't stop when it reaches end of container #4

Open
keithamus opened this issue Apr 18, 2016 · 0 comments · May be fixed by #5
Open

Doesn't stop when it reaches end of container #4

keithamus opened this issue Apr 18, 2016 · 0 comments · May be fixed by #5

Comments

@keithamus
Copy link

keithamus commented Apr 18, 2016

Hey @jackmoore thanks for the great little pollyfill!

I have a slight problem with it - I am using a long container to stick a block of content to the page as you scroll down. Firefox's position: sticky will move down until the inner element (primary per your vernacular) hits the bottom of the wrapper, and then stops. In your implementation, the content keeps on going.

To illustrate, I've knocked up a quick jsbin, which you can visit here: http://jsbin.com/ruwokecofu/edit?html,css,js.

Here is how firefox (native position: sticky) handles that:
firefox video showing position sticky hitting bottom of container

And here is chrome (your implementation):
chrome video showing the bug with sticky-position


Your code uses position: fixed which I think is most of the problem. I think a correct implementation here would use position: absolute and have to adjust the top on every scroll - until it reached the bottom of the container.

If you'd like @jackmoore - I can spend a bit of time working on a fix and PR it. If you're happy that I go forward with the suggestion outlined above.

keithamus added a commit to keithamus/sticky-position that referenced this issue Apr 18, 2016
This fix sets the top to a maximum of the wrapper's container height,
minus the height of the primary element. In other words, the primary
cannot move beyond its parent container. This is truer to the behaviour
of `position: sticky` in browsers that support it.

Fixes jackmoore#4
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

Successfully merging a pull request may close this issue.

1 participant