Verwendung

Set a value from a rotation gesture.

Dieser Typ wird verwendet von 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} />
  );
}

Typdeklaration

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

Mitglieder 8

NameTypErforderlichBeschreibung
rotationschreibgeschütztGestureSourceJaIts rotation in degrees, added to where the follower was.
typeschreibgeschütztGestureTypeJa—
kindschreibgeschütztGestureKindJa—
configschreibgeschütztReadonly<Record<string, unknown>>Ja—
callbacksschreibgeschütztReadonly<Callbacks<never, never>>Ja—
releasingschreibgeschütztAnimation<unknown>NeinHow the motion values following it let go when it ends.
release(animation: Animation<unknown>) => RotateGestureJaThe 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.
activeschreibgeschütztGestureSourceJa1 while it is active, 0 otherwise.
release — Methodensignaturen

Signaturen

ts
(animation: Animation<unknown>): RotateGesture

Parameter

NameTypErforderlichBeschreibung
animationAnimation<unknown>Ja—

Rückgabe

RotateGesture

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