You’re using onscroll here. Have you thought about using the intersection API? I think it may result in less code and use of modern APIs
Thread
How to create an animated navigation on scroll with Tailwind CSS and JavaScript Read the article, see it live and get the code. — lexingtonthemes.com/tutorials/how-…
no, I haven't tried still with that. Still learning js :-)Thank you for the tip Dexter.