Hooks
useIntersectionAnimation
Tracks section visibility via IntersectionObserver and updates the current index for deck-style navigation.
Usage
useIntersectionAnimation({
sectionsRef,
currentIndexRef,
setCurrentIndex,
isScrollingRef,
threshold: 0.4,
})Installation
npx visor add use-intersection-animationParameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
sectionsRef | React.RefObject<HTMLElement[]> | Yes | -- | Ref to an array of section elements to observe. |
currentIndexRef | React.MutableRefObject<number> | Yes | -- | Mutable ref holding the current visible section index. |
setCurrentIndex | (index: number) => void | Yes | -- | State setter called when the visible section changes. |
isScrollingRef | React.MutableRefObject<boolean> | No | -- | Ref indicating programmatic scrolling is in progress; suppresses index updates when true. |
threshold | number | No | 0.4 | IntersectionObserver visibility threshold (0 to 1). |
Returns
This hook does not return a value.