garand / sticky

jQuery Plugin for Sticky Objects
Other
3.3k stars 1.06k forks source link

Contain within parent #106

Open arnoldbird opened 10 years ago

arnoldbird commented 10 years ago

How can I contain the sticky element within its parent so it doesn't cover my footer when I scroll down?

arnoldbird commented 10 years ago

Looks like I can use http://api.jquery.com/height/ to calculate the height of my footer and then use bottomSpacing to prevent the sticky element from covering the footer.

ashleyblackmore commented 9 years ago

Thanks, really helpful, however I don't understand how to use the height from said jquery calculation in the css. Is that possible?

arnoldbird commented 9 years ago

I used the height in my js. I don't remember the thought process, exactly, but this is what I'm seeing in my js file...

var height = $('#section-footer').height(); $("#some-id").sticky({topSpacing:0, bottomSpacing: height + 20});

ashleyblackmore commented 9 years ago

Thanks!

noxbriones commented 9 years ago

+1 for this. It would be awesome if there is a way to contain within a wrapper or perhaps we can specify which wrapper element to use. Maybe we there's additional option like

parent: "#myWrapper",
containInParent: true
microcipcip commented 9 years ago

Thanks, this fix works perfectly