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

Let sticky element work inside overflow: scroll containers #47

Open
tegola opened this issue Apr 8, 2014 · 27 comments
Open

Let sticky element work inside overflow: scroll containers #47

tegola opened this issue Apr 8, 2014 · 27 comments

Comments

@tegola
Copy link

tegola commented Apr 8, 2014

Hello,
Sticky-Kit relies on the body scroll values to work, but since my web app uses divs as main containers, the body never scroll.

Here's an oversimplified version of what I mean:
http://jsbin.com/yitoheno/4

Is there a workaround for this? Maybe the plugin already accounts for this and I'm missing something?

Thanks!

@frenetic
Copy link

frenetic commented Jun 9, 2014

If you take a look at the Sticky-kit website, you will see that your statement isnt true, since the examples are working on scrolling divs.
In this example you linked, it isnt working because you linked to the wrong file. At least, thats the error message being displayed by firebug.
Check that and update this issue.

@eddOrnelas
Copy link

i have updated that example, but neither i has capable to stick on scrolling div (overflow:scroll), there is another way to do this?

regards

@tegola
Copy link
Author

tegola commented Jul 18, 2014

Sorry for the delay. I have updated that example too, and I can't get it to work anyway:
http://jsbin.com/yitoheno/8

@chriscamplin
Copy link

Having the same issue here & wondered if there was advice on a solution.

@phr3qu3ncy
Copy link

@frenetic if i understand it correctly, the examples on the website are in frames as opposed to divs.

also following to see if anyone has come up with a solution for this.

@guyisra
Copy link

guyisra commented Dec 27, 2014

+1

@chrsalbert
Copy link

+1, got the same request.

@danschauder
Copy link

+1, I'm having the same issue. Website examples look perfect, but they use iframes rather than divs. It would be awesome if this worked on divs with overflow:auto, but I haven't been able to make this work without relying on the body scroll

@lafourmirouge
Copy link

+1

2 similar comments
@joermungandr
Copy link

+1

@rosgzc
Copy link

rosgzc commented Feb 4, 2015

+1

@leafo leafo changed the title Stick inside a div instead of body Let sticky element work inside overflow: scroll containers Apr 30, 2015
@tegola
Copy link
Author

tegola commented Jun 22, 2015

I'm glad this has been acknowledged and set as an enhancement. Any estimate?

@lucasstinis
Copy link

+1

@PrincessRebaula
Copy link

hi, can you provide as a demo page, that is easier to understand instead?
just a simple website page that use this plugin, a simple code that non pro can understand and just copy the code and just change the content.

@metavoid
Copy link

Hi, i've tried this trick with foundation 5 framework sidebar and custom offcanvas with wrapper for whole document with pseudo-scroll (overflow: auto). Change in your source code of sticky kit lib this lines. Change 'win' variable link from window object to your element with scroll. Then edit line 85-90 - code of spacer-wrapper so that its height would be equal the height of your main container (only if you have some bugs with the spacer element and it parent(spacer) gets wrong height). In this case also delete float attribute.

  1. win = $('YOUR_ELEMENT_WITH_SCROLL');
    ....

if (spacer) {
spacer.css({
width: elm.outerWidth(true),
height: $('YOUR_MAIN_CONTAINER"]').height(),
display: elm.css("display"),
"vertical-align": elm.css("vertical-align")
// DELETE FLOAT ATTR
});

Optionally, I added location.reload() on resize event on scroll element, because iframes have wrong size after sticky recal method.

@bawpcwpn
Copy link

+1 on this.

Would a suitable solution involve being able to designate what the overflow container is as an option when initialising the plugin?

@tegola
Copy link
Author

tegola commented Oct 15, 2015

Actually, Waypoints Sticky plugin does this already. For now I've switched to that whenever possible.

@tegola
Copy link
Author

tegola commented Jan 12, 2016

Any update on this?

@chrsalbert
Copy link

I think it stuck. :(

@ale24
Copy link

ale24 commented Aug 7, 2016

Is there any way to Stick inside a div instead of body or Let sticky element work inside overflow: scroll containers now?

@tegola
Copy link
Author

tegola commented Aug 8, 2016

@ale24 I'm not aware of a solution in Sticky Kit. As I already said, I've switched to Waypoints Sticky plugin.

@ale24
Copy link

ale24 commented Aug 9, 2016

@tegola Do you have any examples with parallel scrolling sidebars in Waypoints Sticky plugin, cause I am not familar with this plugin at all?

@tegola
Copy link
Author

tegola commented Aug 9, 2016

@ale24 What you mean with "parallel scrolling sidebars"?

@ale24
Copy link

ale24 commented Aug 9, 2016

@tegola I mean this http://codepen.io/anon/pen/oLQaJW

@tegola
Copy link
Author

tegola commented Aug 9, 2016

I do not have an example for something like that, sorry.

Keep in mind that Waypoints' Sticky plugin needs you to make the work for calculating the offsets, while Sticky Kit does them for you (which, I think, is the reason it still doesn't support sticky elements in divs).

@tsnolan23
Copy link

Was there ever any update on this? I still can't use it on any div that isn't the body scroll event.

@NewWorldOrderly
Copy link

+1

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

No branches or pull requests