Primitives / foldkit-primitives/motion

Tween

const · packages/primitives/src/motion/tween.ts:25

Args{ from: number, to: number, ms: number }
Model{ value: number, running: boolean }
MessagesStarted, Stopped, Ticked { value: number }, Finished { value: number }
Its full type
const Tween: Bundle.Bundle<
  'Tween',
  { readonly from: number; readonly to: number; readonly ms: number },
  { readonly value: number; readonly running: boolean },
  | { readonly _tag: 'Started' }
  | { readonly _tag: 'Stopped' }
  | { readonly _tag: 'Ticked'; readonly value: number }
  | { readonly _tag: 'Finished'; readonly value: number },
  never,
  never,
  never,
  void,
  {},
  {}
>

A tween as a bundle: a number animated from one value to another over a duration, in the Model. Progress comes from Effect's clock, so tests drive it with TestClock; the stream ends with Finished, and the value rests at to. Linear interpolation only: easing curves stay the application's job.

In the guides