DOM & Events
useIntersectionObserver
Detect when elements enter or leave the viewport for lazy loading and animations.
import { useIntersectionObserver } from "saha-ui"Uses
Detect element visibility with Intersection Observer. Also includes `useInfiniteScroll` helper that returns a sentinel ref.
Props
| Name | Type | Description | Default |
|---|---|---|---|
| ref | RefObject | Target element ref. | - |
| options | IntersectionObserverInit | Options such as threshold/rootMargin. | - |
Returns
| Name | Description |
|---|---|
| isIntersecting | Boolean whether element intersects viewport. |
Example
const sentinelRef = useInfiniteScroll(loadMore, hasMore); <div ref={sentinelRef}>Loading...</div>Notes
The infinite scroll hook observes the sentinel and calls your callback when it becomes visible.