sticky-kit icon indicating copy to clipboard operation
sticky-kit copied to clipboard

Let sticky element work inside overflow: scroll containers

Open tegola opened this issue 11 years ago • 27 comments

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!

tegola avatar Apr 08 '14 09:04 tegola

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.

frenetic avatar Jun 09 '14 19:06 frenetic

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

eddOrnelas avatar Jun 20 '14 21:06 eddOrnelas

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

tegola avatar Jul 18 '14 16:07 tegola

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

chriscamplin avatar Dec 04 '14 17:12 chriscamplin

@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.

phr3qu3ncy avatar Dec 10 '14 16:12 phr3qu3ncy

+1

guyisra avatar Dec 27 '14 08:12 guyisra

+1, got the same request.

chrsalbert avatar Jan 09 '15 11:01 chrsalbert

+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

danschauder avatar Jan 13 '15 21:01 danschauder

+1

lafourmirouge avatar Feb 01 '15 23:02 lafourmirouge

+1

joermungandr avatar Feb 03 '15 14:02 joermungandr

+1

rosgzc avatar Feb 04 '15 18:02 rosgzc

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

tegola avatar Jun 22 '15 09:06 tegola

+1

lucasstinis avatar Jul 04 '15 22:07 lucasstinis

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.

PrincessRebaula avatar Jul 13 '15 01:07 PrincessRebaula

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.

metavoid avatar Jul 15 '15 03:07 metavoid

+1 on this.

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

bawpcwpn avatar Oct 15 '15 01:10 bawpcwpn

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

tegola avatar Oct 15 '15 08:10 tegola

Any update on this?

tegola avatar Jan 12 '16 16:01 tegola

I think it stuck. :(

chrsalbert avatar Apr 29 '16 08:04 chrsalbert

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

ale24 avatar Aug 07 '16 13:08 ale24

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

tegola avatar Aug 08 '16 19:08 tegola

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

ale24 avatar Aug 09 '16 08:08 ale24

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

tegola avatar Aug 09 '16 09:08 tegola

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

ale24 avatar Aug 09 '16 11:08 ale24

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).

tegola avatar Aug 09 '16 20:08 tegola

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

tsnolan23 avatar Apr 11 '17 16:04 tsnolan23

+1

NewWorldOrderly avatar Nov 16 '19 00:11 NewWorldOrderly