Core API Reference

Complete reference for @reelkit/core configuration, callbacks, methods, and state.

Config Options

PropertyTypeDefaultDescription
countnumberrequiredTotal number of items
initialIndexnumber0Starting index
direction'vertical' | 'horizontal''vertical'Scroll direction
enableGesturesbooleantrueEnable touch/mouse drag navigation. When false, the gesture controller is not attached.
enableNavKeysbooleantrueEnable keyboard arrow key navigation
enableWheelbooleanfalseEnable mouse wheel
wheelDebounceMsnumber200Wheel debounce time
loopbooleanfalseLoop navigation
transitionDurationnumber300Animation duration in ms
swipeDistanceFactornumber0.12Swipe threshold (0-1)
rangeExtractor(index: number, count: number, loop: boolean) => number[]defaultRangeExtractorCustom function to determine which indexes are rendered

Callbacks

CallbackTypeDescription
onBeforeChange(index, nextIndex, rangeIndex) => voidBefore slide change
onAfterChange(index, rangeIndex) => voidAfter slide change
onDragStart(index) => voidDrag started
onDragEnd(index) => voidDrag ended
onDragCanceled(index) => voidDrag canceled
onTap(event: GestureCommonEvent) => voidSingle tap (delayed by double-tap window)
onDoubleTap(event: GestureCommonEvent) => voidDouble tap detected
onLongPress(event: GestureCommonEvent) => voidLong press detected
onLongPressEnd(event: GestureEvent) => voidPointer released after long press
onNavKeyPress(increment: -1 | 1) => voidCustom handler for arrow key navigation. Replaces default prev/next behavior.

Methods

MethodTypeDescription
attach(element)(HTMLElement) => voidConnect controller to DOM element for gesture detection
detach()() => voidDetach DOM listeners (gestures, keyboard, wheel). Safe for re-attach via observe(). Use for React effect cleanup.
dispose()() => voidPermanent teardown: detaches all controllers and cleans up signal observers. Use for Angular onDestroy.
observe()() => voidStart gesture, keyboard, and wheel observation. Respects enableGestures, enableNavKeys, and enableWheel config flags.
unobserve()() => voidStop gesture, keyboard, and wheel observation
next()() => Promise<void>Go to next slide
prev()() => Promise<void>Go to previous slide
goTo(index, animate?)(number, boolean?) => Promise<void>Go to specific slide
adjust(duration?)(number?) => voidRecalculate slide positions
setPrimarySize(size)(number) => voidUpdate container size
updateConfig(config)(Partial<SliderConfig>) => voidUpdate configuration options
updateEvents(events)(Partial<SliderEvents>) => voidReplace event handlers (existing handlers not included are preserved)
getRangeIndex()() => numberReturns the position of the active index within the visible range array

State Properties

PropertyTypeDescription
indexSignal<number>Current slide index
axisValueSignal<AnimatedValue>Current axis position value (animated)
indexesComputedSignal<number[]>Visible indexes for virtualization

Range Extractor

ExportTypeDescription
defaultRangeExtractor(index: number, count: number, loop: boolean) => number[]Default extractor that renders 3 items around current index

Signal API

Lightweight reactive primitives used throughout the core.

Signal Interface

MemberTypeDescription
valueTGet or set the current value. Setting notifies observers if the value changed.
observe(callback)(callback: () => void) => () => voidRegister a listener called on each value change. Returns a dispose function that removes the listener.

Factory Functions

ExportTypeDescription
createSignal<T>(initial: T) => Signal<T>Create a mutable reactive signal
createComputed<T>(fn: () => T, deps: () => Subscribable[]) => ComputedSignal<T>Create a derived computed signal. The second argument is a deps factory that returns the signals to track.
reaction(deps: () => Subscribable[], effect: () => void) => () => voidRun side effect when any dependency signal changes; returns dispose function. Read signal values inside the effect callback.
batch(fn: () => void) => voidGroup multiple signal updates into a single notification pass; supports nesting

Transitions

Built-in transition functions that compute per-slide CSS transforms during animated navigation. Pass one as the transitionTransformFn prop to the framework component.

ExportTypeDescription
TransitionTransformFntypeSignature for custom transition functions
getSlideProgress(axisValue: number, slideIndex: number, primarySize: number) => numberReturns a normalized offset (-1 to 1) for a slide relative to the viewport. Use inside custom transition functions.
slideTransitionTransitionTransformFnDefault slide transition (translateX/Y)
fadeTransitionTransitionTransformFnCrossfade opacity transition
flipTransitionTransitionTransformFn3D card-flip transition
cubeTransitionTransitionTransformFn3D cube rotation transition
zoomTransitionTransitionTransformFnScale/zoom transition

Content Loading

Utilities for tracking per-slide loading/error states and preloading media. The loading controller uses an index guard to reject stale callbacks from previously active slides. The preloader uses an LRU cache (default 200 loaded, 100 errored) so revisiting a broken URL shows the error instantly without retry.

ExportTypeDescription
createContentLoadingController() => ContentLoadingControllerPer-slide loading/error state tracking
createContentPreloader(config: ContentPreloaderConfig) => ContentPreloaderLRU-cached media preloader with error caching
observeMediaLoading(video: HTMLVideoElement, callbacks: MediaLoadingCallbacks) => () => voidObserves video loading state (playing, canplaythrough, waiting). Returns a disposer.

ContentLoadingController

ExportTypeDescription
isLoadingSignal<boolean>Whether the active slide is loading
isErrorSignal<boolean>Whether the active slide has errored
setActiveIndex(index: number) => voidUpdate active index, resets loading/error state
onReady(index: number) => voidMark slide as ready (ignored if index doesn't match active)
onWaiting(index: number) => voidMark slide as loading (ignored if index doesn't match active)
onError(index: number) => voidMark slide as errored (ignored if index doesn't match active)

ContentPreloader

ExportTypeDescription
preload(src: string, type?: "image" | "video") => voidStart preloading a media URL
isLoaded(src: string) => booleanCheck if URL is in the loaded LRU cache (max 200)
isErrored(src: string) => booleanCheck if URL is in the error LRU cache (max 100)
markLoaded(src: string) => voidManually mark a URL as loaded
markErrored(src: string) => voidManually mark a URL as errored
onLoaded(src: string, cb: () => void) => () => voidSubscribe to load completion; returns disposer

Sound

Shared mute/unmute state for media playback. The sound controller provides a reactive muted signal that can be synced to video elements and toggled from custom controls.

ExportTypeDescription
createSoundController() => SoundControllerShared mute state controller
syncMutedToVideo(video: HTMLVideoElement, sound: SoundController) => () => voidSyncs the muted signal to a video element. Returns a disposer.

Timeline

Playback timeline controller for video scrubbing. Tracks duration, current time, buffered ranges, and user scrubbing state as reactive signals. A single call wires pointer and keyboard interactions onto any DOM element so it behaves as a native-feeling scrub bar, with pointer capture, live seeking, and full keyboard support (arrows, Home/End, PageUp/PageDown).

ExportTypeDescription
createTimelineController(config?: TimelineControllerConfig) => TimelineControllerFactory returning a controller with duration, currentTime, progress, bufferedRanges, and isScrubbing signals plus attach, detach, bindInteractions, and seek methods.
TimelineControllerConfiginterfacekeyboardStepSeconds (default 5), keyboardPageFraction (default 0.1), and onSeek, onScrubStart, onScrubEnd callbacks.
BufferedRange{ start: number; end: number }A single contiguous buffered region expressed as 0–1 fractions of total duration. Emitted sorted and non-overlapping.

Fullscreen

Cross-browser fullscreen utilities with Safari vendor-prefix guards. The fullscreen signal is a lazy singleton that tracks fullscreen state reactively.

ExportTypeDescription
fullscreenSignalSignal<boolean>Reactive signal tracking whether the document is in fullscreen mode
requestFullscreen(element: HTMLElement) => Promise<void>Enter fullscreen on the given element
exitFullscreen() => Promise<void>Exit fullscreen mode

DOM & Cleanup Utilities

Low-level helpers for DOM event management and deterministic cleanup. Used internally by all controllers and available for custom integrations.

ExportTypeDescription
observeDomEvent(target, event, handler, options?) => () => voidAdds a DOM event listener and returns a disposer that removes it
createDisposableList() => DisposableListComposable list for collecting disposer functions. Call dispose() to run all at once.
createBodyLock() => BodyLockReference-counted body scroll lock. Multiple consumers can lock simultaneously; scroll is restored when all unlock.
sharedBodyLockBodyLockModule-level singleton instance. Use when multiple components across your app should share a single reference counter so nested modals/overlays interleave correctly. Framework bindings (@reelkit/react, @reelkit/vue, @reelkit/angular) use this under the hood.

Focus Management

Framework-agnostic dialog a11y primitives. The overlay packages use them to return focus to the trigger on close and trap Tab / Shift+Tab inside the overlay while it's open. SSR-safe: each helper returns a no-op disposer in non-browser environments.

ExportTypeDescription
captureFocusForReturn() => DisposerCaptures the currently focused element and returns a disposer that focuses it again. Best-effort: the disposer is a no-op if the captured element has since been removed from the DOM.
createFocusTrap(container: HTMLElement) => DisposerTraps Tab/Shift+Tab inside container. Tab at the last focusable wraps to the first; Shift+Tab at the first wraps to the last; focus that escapes the container (click outside, programmatic focus) is pulled back. Does not move focus into the container on activation — the caller decides.
getFocusableElements(container: HTMLElement) => HTMLElement[]Returns every keyboard-focusable descendant in DOM order, skipping disabled, hidden, and tabindex="-1" elements.

Usage

typescript

Video Utilities

Framework-agnostic utilities for shared video playback across slides. Used internally by @reelkit/react-reel-player and @reelkit/react-lightbox, available for custom framework bindings.

ExportTypeDescription
captureFrame(video: HTMLVideoElement) => string | nullCaptures the current video frame as a JPEG data URL. Returns null on cross-origin errors.
createSharedVideo(config: SharedVideoConfig) => SharedVideoInstanceCreates a scoped shared video singleton with playback position and frame capture maps. Each consumer gets an isolated instance for iOS sound continuity.
syncVideoObjectFit(video: HTMLVideoElement, fallbackIsVertical: boolean) => DisposerKeeps video.style.objectFit in sync with the video's real orientation. Applies the fallback (from the declared aspect ratio) immediately, then on loadedmetadata reads actual videoWidth / videoHeight and switches to 'cover' for portrait, 'contain' for landscape. Resilient to wrong declared metadata.