garand / sticky

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

make element sticky directly on load #269

Closed DanielRuf closed 4 years ago

DanielRuf commented 6 years ago

Sometimes you have an element like a header which should be directly sticky on documentready/load based on other things (like the viewport).

Currently it does not work when the element sits directly at the top (scrollTop 0). It never adds the classes or fires the sticky method.

garand commented 6 years ago

@DanielRuf In that case I would recommend using position:fixed in your CSS.

DanielRuf commented 6 years ago

@DanielRuf In that case I would recommend using position:fixed in your CSS.

Right, this is the approach that we chose in the end. But it would be good to also make this dynamic with the script to have a better control based on other things on the website.

I guess there a >= somewhere which prevents this usecase.