How can I change Navbar background colour when toggled div arrived the viewport?

Good afternoon, I want the Navbar's colour changes when the specific DIV arrived the viewport, currently I use the window.scrollY listener but it works poorly when the page size changed. Is there any better method? Thank you The DIV will have an ID.
3 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
William_O^2
William_O^2OP3y ago
Kevin Powell
YouTube
How to change your navigation style on scroll
This video explores using the Intersection Observer API to watch for an element leaving the page and then changing the style of a fixed navigation bar. GitHub repo: https://github.com/kevin-powell/navbar-change-on-scroll (includes start and finished versions) I set up some custom properties ahead of time to make the change really super simple,...
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server