Usage

Recognize a directional swipe.

This type is used by fling

tsx
// Recognize a directional swipe.
import { Box, fling, signal } from 'kuito';

const page = signal(0);

const swipe = fling({
  direction: ['left', 'right'],
  onEnd: (event, success) => {
    if (success) page.value += 1;
  },
});

<Box gestures={[swipe]} />;

Type declaration

ts
export interface Gesture {
  readonly __kuitoGesture: 'gesture';
  readonly type: GestureType;
  readonly kind: GestureKind;
  readonly config: Readonly<Record<string, unknown>>;
  readonly callbacks: Readonly<Callbacks<never, never>>;
  /** How the motion values following it let go when it ends. */
  readonly releasing?: Animation<unknown>;
  /**
   * The same gesture, letting go with `animation`: each follower runs it with
   * the gesture's velocity, toward its own home (its first value) unless the
   * animation names a target.
   */
  release(animation: Animation<unknown>): this;
  /** 1 while it is active, 0 otherwise. */
  readonly active: GestureSource;
}

Members 7

NameTypeRequiredDescription
typereadonlyGestureTypeYes—
kindreadonlyGestureKindYes—
configreadonlyReadonly<Record<string, unknown>>Yes—
callbacksreadonlyReadonly<Callbacks<never, never>>Yes—
releasingreadonlyAnimation<unknown>NoHow the motion values following it let go when it ends.
release(animation: Animation<unknown>) => GestureYesThe same gesture, letting go with animation: each follower runs it with the gesture's velocity, toward its own home (its first value) unless the animation names a target.
activereadonlyGestureSourceYes1 while it is active, 0 otherwise.
release — method signatures

Signatures

ts
(animation: Animation<unknown>): Gesture

Parameters

NameTypeRequiredDescription
animationAnimation<unknown>Yes—

Returns

Gesture

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