Usage

Add haptic feedback to a gesture.

tsx
// Add haptic feedback to a gesture.
import { Box, haptics, pan, type Callbacks, type PanChangeEvent, type PanEvent } from 'kuito';

// Shared feedback for every draggable in the app.
const feedback: Callbacks<PanEvent, PanChangeEvent> = {
  onStart: () => void haptics.selection(),
  onEnd: (_, success) => void (success && haptics.impact('light')),
};

<Box gestures={[pan({ axis: 'x', ...feedback })]} />;

Type declaration

ts
export interface Callbacks<Event, Change> {
  /** It activated. */
  onStart?: (event: Event) => void;
  /** It moved, with the change since the last move. */
  onChange?: (event: Change) => void;
  /** It ended after activating: `success` is false when it was cancelled. */
  onEnd?: (event: Event, success: boolean) => void;
}

Members 3

NameTypeRequiredDescription
onStart(event: Event) => voidNoIt activated.
onChange(event: Change) => voidNoIt moved, with the change since the last move.
onEnd(event: Event, success: boolean) => voidNoIt ended after activating: success is false when it was cancelled.
onStart — method signatures

Signatures

ts
(event: Event): void

Parameters

NameTypeRequiredDescription
eventEventYes—

Returns

void

onChange — method signatures

Signatures

ts
(event: Change): void

Parameters

NameTypeRequiredDescription
eventChangeYes—

Returns

void

onEnd — method signatures

Signatures

ts
(event: Event, success: boolean): void

Parameters

NameTypeRequiredDescription
eventEventYes—
successbooleanYes—

Returns

void

Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.