Does HTML-CSS transition fail when class of sticky element changes?
I want to do a transition when the element gets sticky. But it can't be done with this below code. const content = document.querySelector('.contents'); const initalPos = content.offsetTop; window.addEventListener("scroll", () => { if(content.offsetTop > initalPos) { content.classList.add('stuck'); } else {…