useIntersectionObserver
Watch for intersection changes of a target element.
Demo
Scroll down 👇
I'm the target! 🎯
Element outside the viewport
Usage
With a reference to an element, you can use the useIntersectionObserver
utility to watch for
intersection changes of the target element.
Pause
You can pause the intersection observer at any point by calling the pause
method.
Resume
You can resume the intersection observer at any point by calling the resume
method.
Stop
You can stop the intersection observer at any point by calling the stop
method.
isActive
You can check if the intersection observer is active by checking the isActive
property.
Warning
This property cannot be destructured as it is a getter. You must access it directly from the observer.