Skip to content

NumberAnimation

An animation component that eases a number from its current value to the target value, stops at the target and emits oas-finish; under prefers-reduced-motion it jumps straight to the target, and disconnecting cancels the rAF without leaks.

Basic Usage

Default 1500ms roll from 0 to target

Speed and Decimal Places

duration=3000 + to-fixed=2

Finish Event

oas-finish callback

API

Attributes

AttributeDescriptionTypeDefault
durationAnimation duration (ms); 0 jumps straight to the targetnumber | string
to-fixedDecimal places (Number.prototype.toFixed); when omitted, integer displaystring
valueTarget value; invalid values treated as 0string0

Events

EventDescription
oas-finishEmitted once when the animation reaches the target, detail { value: target value }
  • Changing value mid-animation continues from the currently displayed value to the new target.
  • When the system enables "reduce motion", the animation is skipped and the target value is shown directly (oas-finish is still emitted).
  • On disconnect, any unfinished rAF is cancelled — no leaks.