Utilisation

Configure a directional flick.

tsx
// Configure a directional flick.
import { Box, fling, haptics, type FlingOptions } from 'kuito';

function swipeTo(direction: 'left' | 'right', action: () => void): FlingOptions {
  return {
    direction,
    hitArea: { horizontal: 20 },
    onEnd: (_, success) => {
      if (!success) return;
      void haptics.impact('light');
      action();
    },
  };
}

<Box
  gestures={[
    fling(swipeTo('left', () => console.log('archive'))),
    fling(swipeTo('right', () => console.log('pin'))),
  ]}
/>;

Déclaration du type

ts
export interface FlingOptions extends Common, Callbacks<FlingEvent, FlingEvent> {
  /** Where it may go; right by default. */
  direction?: FlingDirection | readonly FlingDirection[];
}

Membres 6

NomTypeRequisDescription
directionFlingDirection | readonly FlingDirection[]NonWhere it may go; right by default.
disabledbooleanNonIgnores touches, like a disabled Pressable.
hitAreaHitAreaNonInsets of the area that takes touches: one for every edge, or by edge.
onStart(event: PositionEvent) => voidNonIt activated.
onChange(event: PositionEvent) => voidNonIt moved, with the change since the last move.
onEnd(event: PositionEvent, success: boolean) => voidNonIt ended after activating: success is false when it was cancelled.
onStart — signatures de méthode

Signatures

ts
(event: PositionEvent): void

Paramètres

NomTypeRequisDescription
eventPositionEventOui—

Retourne

void

onChange — signatures de méthode

Signatures

ts
(event: PositionEvent): void

Paramètres

NomTypeRequisDescription
eventPositionEventOui—

Retourne

void

onEnd — signatures de méthode

Signatures

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

Paramètres

NomTypeRequisDescription
eventPositionEventOui—
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.