Managing Scroll Events
Tying animations or state changes to the scroll event is historically terrible for browser performance. Modern implementations should rely entirely on IntersectionObserver.
IntersectionObserver allows the browser to asynchronously calculate when an element enters or exits the viewport, avoiding the synchronous layout thrashing caused by traditional scroll listeners.