An event for CSS position: sticky
Here’s a secret: You may not need
scroll
events in your next app. Using anIntersectionObserver
, I show how you can fire a custom event whenposition:sticky
elements become fixed or when they stop sticking. All without the use of scroll listeners.[…]
One of the practical limitations of using CSS sticky position is that it doesn’t provide a platform signal to know when the property is active. In other words, there’s no event to know when an element becomes sticky or when it stops being sticky.