Skip to content

RiffleHandle

Defined in: react/useRiffle.ts:36

What useRiffle returns: the imperative handle plus a pair of prop getters that wire whatever markup you render to the engine.

import { useRiffle } from '@rpxl/riffle/react'
function Stack({ films }: { films: { title: string }[] }) {
const riffle = useRiffle({ count: films.length, cardWidth: 300, cardHeight: 400 })
return <div {...riffle.getRootProps()} />
}
  • Pick<AdapterHandle, "instance" | "subscribe" | "getSnapshot" | "on" | "next" | "prev" | "goTo">

readonly instance: Riffle | null

Defined in: adapter.ts:26

The live engine, or null before the container mounts and after it unmounts.

AdapterHandle.instance

getCardProps<P>(index, props?): P & object

Defined in: react/useRiffle.ts:50

Props for the card at index. Your own props win, except ref, which is composed. Pass a stable ref: one whose identity changes every render re-registers that card with the engine on every render too. Harmless (registerCard is idempotent for the same element), but wasted work.

P extends ElementProps

number

P

P & object


getRootProps<P>(props?): P & object

Defined in: react/useRiffle.ts:41

Props for the stack container. Your own props win, except ref, which is composed.

P extends ElementProps

P

P & object


getSnapshot(): RiffleSnapshot

Defined in: adapter.ts:68

Referentially stable while nothing has changed, including across mount.

RiffleSnapshot

AdapterHandle.getSnapshot


goTo(index, opts?): void

Defined in: adapter.ts:76

Moves to index, animated unless opts.animate is false. A no-op while unmounted.

number

boolean

void

AdapterHandle.goTo


next(): void

Defined in: adapter.ts:72

Advances to the next card, animated. A no-op while unmounted.

void

AdapterHandle.next


on<K>(event, fn): () => void

Defined in: adapter.ts:70

Subscribes to one engine event. Returns an unsubscribe function; a no-op while unmounted.

K extends keyof RiffleEventMap

K

(payload) => void

() => void

AdapterHandle.on


prev(): void

Defined in: adapter.ts:74

Moves to the previous card, animated. A no-op while unmounted.

void

AdapterHandle.prev


subscribe(listener): () => void

Defined in: adapter.ts:66

Notified whenever getSnapshot() would return a new value. Returns an unsubscribe function.

() => void

() => void

AdapterHandle.subscribe