Skip to content

useRiffle()

useRiffle(options): object

Defined in: vue/useRiffle.ts:20

Accepts a ref, a getter, or a plain options object, and returns state, activeIndex, the two directives (vRiffleRoot, vRiffleCard), and the imperative handle (next, prev, goTo, on, instance). Options are compared with the previous set inside a watch, and only what changed reaches the engine’s update().

MaybeRefOrGetter<RiffleOptions>

activeIndex: ComputedRef<number>

goTo: (index, opts?) => void = handle.goTo

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

number

boolean

void

next: () => void = handle.next

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

void

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

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

K extends keyof RiffleEventMap

K

(payload) => void

() => void

prev: () => void = handle.prev

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

void

state: ShallowRef<RiffleSnapshot, RiffleSnapshot>

vRiffleCard: Directive<HTMLElement, number>

vRiffleRoot: Directive<HTMLElement>

get instance(): Riffle | null

Riffle | null

import { useRiffle } from '@rpxl/riffle/vue'
const films = [{ title: 'Neon Harbor' }]
const riffle = useRiffle(() => ({ count: films.length, cardWidth: 300, cardHeight: 400 }))