leafo / sticky-kit

A jQuery plugin for creating smart sticky elements
http://leafo.net/sticky-kit
2.9k stars 517 forks source link

Suggestion: change "scroll < top" to "scroll <= top" on line 140 #228

Open brandonpeat opened 7 years ago

brandonpeat commented 7 years ago

Apologies, I'm a Github newbie, this is probably the wrong forum in which to offer suggestions?

In "jquery.sticky-kit.js" I suggest changing line 140 from if (scroll < top) { to if (scroll <= top) {.

If like me you're using Sticky-Kit to stick a header at the very top of your screen and change its CSS on scrolling (like #header{background:#fff} #header.is_stuck{background:#000} or some such), the "is_stuck" class applies on scroll but is never removed when you scroll back to the top. It's on that header permanently until you reload. The above tweak solved my issue.

I'm not a jquery expert so maybe there's a reason for the existing method I've overlooked? Thanks!

brandonpeat commented 7 years ago

Aha, looks like somebody beat me to it: https://github.com/leafo/sticky-kit/pull/117