I'm using the new position: sticky
(info) to create an iOS-like list of content.
It's working well and far superior than the previous JavaScript alternative (example) however as far as I know no event is fired when it's triggered, which means I can't do anything when the bar hits the top of the page, unlike with the previous solution.
I'd like to add a class (e.g. stuck
) when an element with position: sticky
hits the top of the page. Is there a way to listen for this with JavaScript? Usage of jQuery is fine.