← Your scroll listener fires on every pixel. `IntersectionObserver` fires when visibility actually changes.
Playground
IntersectionObserver — interactive playground
preview
Edits run in a sandbox in your browser — nothing is saved and nothing leaves the page.