VisorVisor
Hooks

useSlideEngine

Provides smooth-scroll navigation between sections with scroll-snap coordination and debounced locking.

Usage

const { goTo, navigateTo, isScrollingRef } = useSlideEngine({
  containerRef,
  sectionsRef,
  currentIndexRef,
  setCurrentIndex,
})

Installation

npx visor add use-slide-engine

Parameters

NameTypeRequiredDefaultDescription
containerRefReact.RefObject<HTMLElement | null>No--Container element that scrolls. Falls back to scrollIntoView if not provided.
sectionsRefReact.RefObject<HTMLElement[]>Yes--Ref to an array of section elements that can be navigated.
currentIndexRefReact.MutableRefObject<number>Yes--Mutable ref holding the current section index.
setCurrentIndex(index: number) => voidNo--State setter called when navigation occurs.

Returns

NameTypeDescription
goTo(index: number) => voidScrolls to the section at the given index with smooth animation.
navigateTo(id: string) => voidScrolls to a section by its DOM element id.
isScrollingRefReact.MutableRefObject<boolean>Ref indicating whether a programmatic scroll is in progress.