I am facing an issue with an element positioned at the top of the screen using position:sticky;
. I have implemented a JS scroll eventlistener to add a stuck
class when the element becomes stuck (scroll Y is greater than 0).
The presence of the stuck
class causes an element inside the sticky element, which has CSS transition, to decrease in height.
However, scrolling very slowly results in the height change causing the scrollY to suddenly jump back to zero, removing the stuck
class. This creates a jolty scrolling loop that continues infinitely until you scroll faster and outscroll the problem.
I am seeking advice on how to achieve smooth scrolling when using position: sticky
. You can view the issue live here: