Is it possible with jQuery or JS to detect when an element has become "stuck", from the css property, position: sticky?
I've attached a screenshot of the interface that I am trying to recreate.
If you look at the attached image, basically, when you scroll down the page, the purple tiles become "stuck", using the CSS property position: sticky
.
When you scroll, I want it so that the correct letter in the alphabetical list at the top (in the light blue bar), becomes highlighted.
So essentially, I need to figure out a way to detect which tile is currently stuck to the top. I am asking if there is a jquery or javascript event to detect this.
Something like:
if ($("#a-tile").is(":sticky")) {
$(".alphabet-nav-link[data-rel-id='a']").addClass("active");
}
Naturally, that doesn't work, and various Google searches have not shown much by way of results.
Is anybody aware of a way to do this?