Having trouble with the Intersection Observer API. Attempting to use it to show a nav-bar with a white background fixed to the viewport once it scrolls out of view.
Initially tested using console.log('visible') successfully to determine visibility, but ran into issues when applying a new class upon invisibility. The page went haywire, constantly toggling classes and displaying "visible" and "not visible".
Suspect the issue may be related to changes in rootMargin when applying the class, but unsure how to resolve it.
Code for my entire website can be found here:
PS: Only responsible for app.js, HTML and CSS are from FreeCodeCamp. PS: Apologies for the link, unable to share code with backticks here ^^ Make sure to view the site on a larger screen to see the issue more clearly.
Appreciate any assistance, thank you!