Usage

Set a value from a rotation gesture.

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 RotationEvent extends GestureEvent {
  /** Degrees, as the rotate prop takes them. */
  rotation: number;
  anchorX: number;
  anchorY: number;
  velocity: number;
}

Members 7

NameTypeRequiredDescription
rotationnumberYesDegrees, as the rotate prop takes them.
anchorXnumberYes—
anchorYnumberYes—
velocitynumberYes—
statenumberYes—
numberOfPointersnumberYes—
pointerTypenumberYes—
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.