useIntersectionObserver
React hook for detecting when an element is visible in the viewport using Intersection Observer.
Installation
Example
Usage
Reference
Parameters
elementRef
: Ref object of the element to observe.
args
: Configuration options for Intersection Observer.
threshold
: The ratio of the target's visibility the observer's visibility changes.
root
: The element that is used as the viewport for checking visibility.
rootMargin
: Margin around the root.
freezeOnceVisible
: Flag to freeze the entry once it becomes visible.
Return Value
The IntersectionObserverEntry
for the observed element, or undefined
if Intersection Observer is not supported.
Links
use-intersection-observer.ts