dollarshaveclub / stickybits

Stickybits is a lightweight alternative to `position: sticky` polyfills 🍬
https://github.com/yowainwright/stickybits
MIT License
2.19k stars 167 forks source link

Question: Add class with jquery to other element upon stick? #584

Closed casbboy closed 4 years ago

casbboy commented 4 years ago

Requested Update

Is there a way to run another jquery function at time of "stick"? Doing the jquery stickybits.

I want to add a class to another element (with class) every time it sticks and remove when unsticks.

Cheers! Ryan

yowainwright commented 4 years ago

Adding events, which would do what you're suggested, was discussed in detail. It was decided that if there were multiple stickybit items with the same information—same classes, etc, events could become very confusing.

To solve your issue @casbboy you could 'watch' for a sticky item to have a class and do something. This would be pretty inefficient so I'd recommend not doing it if possible. 😄