VisorVisor
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-animation

Parameters

NameTypeRequiredDefaultDescription
sectionsRefReact.RefObject<HTMLElement[]>Yes--Ref to an array of section elements to observe.
currentIndexRefReact.MutableRefObject<number>Yes--Mutable ref holding the current visible section index.
setCurrentIndex(index: number) => voidYes--State setter called when the visible section changes.
isScrollingRefReact.MutableRefObject<boolean>No--Ref indicating programmatic scrolling is in progress; suppresses index updates when true.
thresholdnumberNo0.4IntersectionObserver visibility threshold (0 to 1).

Returns

This hook does not return a value.