Utilisation

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 })]} />;

Déclaration du type

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;
}

Membres 3

NomTypeRequisDescription
onStart(event: Event) => voidNonIt activated.
onChange(event: Change) => voidNonIt moved, with the change since the last move.
onEnd(event: Event, success: boolean) => voidNonIt ended after activating: success is false when it was cancelled.
onStart — signatures de méthode

Signatures

ts
(event: Event): void

Paramètres

NomTypeRequisDescription
eventEventOui—

Retourne

void

onChange — signatures de méthode

Signatures

ts
(event: Change): void

Paramètres

NomTypeRequisDescription
eventChangeOui—

Retourne

void

onEnd — signatures de méthode

Signatures

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

Paramètres

NomTypeRequisDescription
eventEventOui—
successbooleanOui—

Retourne

void

Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.