Verwendung

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

Typdeklaration

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

Mitglieder 6

NameTypErforderlichBeschreibung
directionFlingDirection | readonly FlingDirection[]NeinWhere it may go; right by default.
disabledbooleanNeinIgnores touches, like a disabled Pressable.
hitAreaHitAreaNeinInsets of the area that takes touches: one for every edge, or by edge.
onStart(event: PositionEvent) => voidNeinIt activated.
onChange(event: PositionEvent) => voidNeinIt moved, with the change since the last move.
onEnd(event: PositionEvent, success: boolean) => voidNeinIt ended after activating: success is false when it was cancelled.
onStart — Methodensignaturen

Signaturen

ts
(event: PositionEvent): void

Parameter

NameTypErforderlichBeschreibung
eventPositionEventJa—

Rückgabe

void

onChange — Methodensignaturen

Signaturen

ts
(event: PositionEvent): void

Parameter

NameTypErforderlichBeschreibung
eventPositionEventJa—

Rückgabe

void

onEnd — Methodensignaturen

Signaturen

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

Parameter

NameTypErforderlichBeschreibung
eventPositionEventJa—
successbooleanJa—

Rückgabe

void

Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.