Usage

Set a value from a rotation gesture.

This type is used by rotate

tsx
// Set a value from a rotation gesture.
import { Box, motion, rotate, spring, type RotationEvent } from 'kuito';

function Dial(props: { onSet: (degrees: number) => void }) {
  const turn = rotate().release(spring());
  const angle = motion(0).follows(turn.rotation);

  const settle = (event: RotationEvent) => props.onSet(Math.round(event.rotation / 15) * 15);

  return (
    <Box rotate={angle} gestures={[rotate({ onEnd: settle }), turn]} width={120} height={120} />
  );
}

Type declaration

ts
export interface RotateGesture extends Gesture {
  /** Its rotation in degrees, added to where the follower was. */
  readonly rotation: GestureSource;
}

Members 8

NameTypeRequiredDescription
rotationreadonlyGestureSourceYesIts rotation in degrees, added to where the follower was.
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>) => RotateGestureYesThe 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>): RotateGesture

Parameters

NameTypeRequiredDescription
animationAnimation<unknown>Yes—

Returns

RotateGesture

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