@neshel-ui/animations/core
Every export of @neshel-ui/animations/core, generated from its declarations.
Experimental and not on npm
Signatures, members and defaults, generated from the built declarations. For explanations and examples read the guide.
animateElementfunction(element: Animated, channel: ExclusiveChannel, keyframes: readonly string[], transition: Transition | undefined, options: AnimateElementOptions): TweenControlanimateValuefunctionAnimate a motion value with a spring (default) or a tween; starts immediately.
(value: MotionValue, target: number, transition?: Transition | undefined, options?: ControlOptions | undefined): MotionControl | TweenControlattachEffectfunctionAttach a definition to an element (full engine: composition and exclusive-channel arbitration).
<Options, Resolved>(element: Element & { readonly style: CSSStyleDeclaration; }, definition: EffectDefinition<Options, Resolved>, options?: Options | undefined, config?: AttachConfig | undefined): EffectHandle<Options>attachPresetfunctionAttach a preset (or a definition) to an element through the full engine.
<Options, Resolved>(element: Element & { readonly style: CSSStyleDeclaration; }, input: PresetInput<Options, Resolved>, overrides?: Partial<Options> | undefined, config?: AttachConfig | undefined): EffectHandle<Options>bindChannelfunctionWrite a motion value into an element channel through its motion host; returns the release function, which restores the captured inline value.
(value: MotionValue, element: Element & { readonly style: CSSStyleDeclaration; }, binding: ChannelBinding, options: { effectId: string; priority?: number | undefined; conflicts?: ConflictPolicy | undefined; }): () => voidcomposeTransformfunction(layers: Iterable<TransformLayer>): stringcreateEffectRegistryfunction(definitions: readonly AnyEffectDefinition[]): EffectRegistrycreateFrameSchedulerfunction(options?: FrameSchedulerOptions | undefined): FrameSchedulercubicBezierfunctionCSS `cubic-bezier()` solved with Newton–Raphson and a bisection fallback (error ≤ 1e-6 in x).
(x1: number, y1: number, x2: number, y2: number): EasingdefineEffectfunction<Options, Resolved>(definition: EffectDefinition<Options, Resolved>): Readonly<EffectDefinition<Options, Resolved>>definePresetfunctionDefine a preset; its options are validated by `effect.resolve` now (same error everywhere).
<Options, Resolved>(name: string, effect: EffectDefinition<Options, Resolved>, options: Options): EffectPreset<Options, Resolved>getFrameSchedulerfunctionThe page-wide scheduler, created on first use (never at import time).
(): FrameSchedulergetMotionDebugInfofunction(element: object): MotionDebugInfo | undefinedmapRangefunction(value: number, inMin: number, inMax: number, outMin: number, outMax: number, options?: { clamp?: boolean | undefined; } | undefined): numbermotionValuefunction(initial: number): MotionValueprefersReducedMotionfunctionCurrent OS/browser preference; `false` on the server or without `matchMedia`.
(): booleanresolveSpringfunctionValidated, complete options; throws `RangeError` for non-finite or out-of-range values.
(options?: SpringOptions | undefined): Required<SpringOptions>shouldReduceMotionfunctionWhether motion must be reduced for `policy` given the system preference.
(policy: ReducedMotion, systemPrefersReduced: boolean): booleanspringEasingfunctionSample a spring from 0 to 1 into a CSS `linear()` easing plus the duration until rest (ms), so CSS and WAAPI drivers keep the spring's character (research R4 of feature 008).
(spring?: SpringOptions | undefined, options?: { points?: number | undefined; } | undefined): { easing: string; duration: number; }stepSpringfunctionAdvance `state` toward `target` by `dt` seconds (mutates `state`). Returns `true` when the spring is at rest on the target.
(state: SpringState, target: number, options: Required<SpringOptions>, dt: number): booleanstepsfunctionCSS `steps(count, jump-start | jump-end)`.
(count: number, position?: "start" | "end" | undefined): EasingsubscribeReducedMotionfunctionCall `listener` whenever the preference changes; returns the unsubscribe function.
(listener: (reduced: boolean) => void): () => voidtoCssEasingfunctionCSS string of a preset or of an easing created by `cubicBezier`/`steps`/`linear`.
(easing: Easing | "linear" | "standard" | "emphasized" | "decelerate" | "accelerate"): stringDEFAULT_SPRINGconstReadonly<Required<SpringOptions>>clampconstPure interpolation helpers (contracts/motion-defaults.md §4).
easingsconstNamed easings (values tuned in 009 with the lab).
Readonly<{ linear: Easing; standard: Easing; emphasized: Easing; decelerate: Easing; accelerate: Easing; }>linearconstmixconstLinear interpolation from `from` to `to` at `t` (not clamped).
motionDefaultsconstReadonly<{ duration: Readonly<{ instant: 0; fast: 120; normal: 200; slow: 320; deliberate: 500; }>; easing: Readonly<{ linear: Easing; standard: Easing; emphasized: Easing; decelerate: Easing; accelerate: Easing; }>; distance: Readonly<{ sm: 4; md: 8; lg: 16; }>; spring: Readonly<{ gentle: Readonly<{ stiffness: 120; damping: 20; mass: 1; }>; snappy: Readonly<{ stiffness: 300; damping: 30; mass: 1; }>; bouncy: Readonly<{ stiffness: 260; damping: 12; mass: 1; }>; }>; }>progressconstInverse of `mix`: where `value` sits between `from` and `to` (0 when they are equal).
NeshelAnimationsErrorclassError thrown for invalid effect usage; identical on the server and the client (ADR 0009 §6).
AnimateElementOptionsinterfaceAnimateElementOptions
AnimateElementOptions Prop Type Default Description conflicts ConflictPolicy— — effectId(required) string— — priority number— — reducedMotion ReducedMotion— — AttachConfiginterfaceAttachConfig
AttachConfig Prop Type Default Description conflicts ConflictPolicy— — priority number— Overrides the definition's priority for this attachment. reducedMotion ReducedMotion— Overrides the policy carried by the options. ChannelHandlesinterfaceChannelHandles
ChannelHandles Prop Type Default Description exclusive(required) (channel: ExclusiveChannel) => { set(value: string): void; clear(): void; }— — opacity(required) { set(value: number): void; clear(): void; }— — transform(required) { set(layer: TransformLayer): void; clear(): void; }— — ControlOptionsinterfaceControlOptions
ControlOptions Prop Type Default Description reducedMotion ReducedMotion— — EffectContextinterfaceEffectContext
EffectContext Prop Type Default Description channels(required) ChannelHandles— — element(required) Element & { readonly style: CSSStyleDeclaration; }— — onReducedChange(required) (listener: (reduced: boolean) => void) => () => void— — options(required) Resolved— — reduced(required) boolean— Whether motion must be reduced now (live). scheduler(required) FrameScheduler— — EffectDefinitioninterfaceEffectDefinition
EffectDefinition Prop Type Default Description channels(required) readonly ChannelClaim[]— — family(required) FamilyId— — id(required) EffectId— — policy (options: Resolved) => ReducedMotion | undefined— Reduced-motion policy carried by the options (e.g. Tilt3D's reducedMotionprop).priority number— — reducedMotion(required) ReducedBehaviour— — resolve(required) (options: Options | undefined) => Resolved— Validates options; throw NeshelAnimationsErrorfor invalid input.setup(required) (context: EffectContext<Resolved>) => EffectInstance<Resolved>— — EffectHandleinterfaceEffectHandle
EffectHandle Prop Type Default Description destroy(required) () => void— Idempotent; releases channels (restoring styles) and every listener. pause(required) () => void— — resume(required) () => void— — state(required) EffectState— — update(required) (options?: Options) => void— — EffectInstanceinterfaceEffectInstance
EffectInstance Prop Type Default Description destroy(required) () => void— Must release every listener and frame task it created. pause () => void— — resume () => void— — update(required) (options: Resolved) => void— — EffectPresetinterfaceEffectPreset
EffectPreset Prop Type Default Description effect(required) EffectDefinition<Options, Resolved>— — name(required) string— Kebab-case preset name, unique within its effect (e.g. "fade-up").options(required) Readonly<Options>— — EffectRegistryinterfaceEffectRegistry
EffectRegistry Prop Type Default Description get(required) (id: string) => AnyEffectDefinition | undefined— — has(required) (id: string) => boolean— — list(required) (family?: FamilyId) => readonly AnyEffectDefinition[]— — FrameInfointerfaceFrameInfo
FrameInfo Prop Type Default Description delta(required) number— Seconds since the previous frame, clamped to maxDelta(0 on the first frame).time(required) number— requestAnimationFrametimestamp (ms).FrameSchedulerinterfaceFrameScheduler
FrameScheduler Prop Type Default Description schedule(required) (task: FrameTask, phase?: FramePhase) => () => void"update"Queue taskinphase(default"update"); returns an idempotent cancel function.size(required) number— Number of pending tasks (diagnostics and tests). FrameSchedulerOptionsinterfaceFrameSchedulerOptions
FrameSchedulerOptions Prop Type Default Description maxDelta number— Upper bound of deltain seconds (default 1/15) so a background tab never "jumps".MotionControlinterfaceMotionControl
MotionControl Prop Type Default Description cancel(required) () => void— — finish(required) () => void— — finished(required) Promise<MotionResult>— Promise of the current run. pause(required) () => void— — play(required) () => void— — reverse(required) () => void— — state(required) MotionState— — MotionDebugInfointerfaceMotionDebugInfo
MotionDebugInfo Prop Type Default Description channels(required) Array<{ channel: string; mode: "compose" | "multiply" | "exclusive"; owner?: string; waiting: string[]; contributions: number; }>— — writes(required) number— — MotionResultinterfaceMotionResult
MotionResult Prop Type Default Description direction(required) MotionDirection— — status(required) "completed" | "cancelled" | "interrupted"— — value(required) number— Final value (JS driver) or progress 0–1 (WAAPI driver). MotionValueinterfaceMotionValue
Motion values: numbers that animate without React state (contracts/controllers.md §3).
MotionValue Prop Type Default Description get(required) () => number— — getVelocity(required) () => number— — set(required) (value: number) => void— Set directly (velocity becomes 0); interrupts nothing by itself. subscribe(required) (listener: (value: number) => void) => () => void— Listener runs synchronously on every change; returns the unsubscribe function. SpringOptionsinterfaceSpringOptions
Damped spring integrator (contracts/core-engine.md §2). Pure and framework-agnostic: the caller owns the state object and the clock. Semi-implicit Euler with fixed sub-steps (at most 1/240 s) keeps the integration stable for any frame rate; the spring snaps to its target once both the distance and the speed fall below the rest thresholds, so an idle effect stops scheduling frames.
SpringOptions Prop Type Default Description damping number26Damping coefficient c (default 26). c >= 2 * sqrt(k * m)never overshoots.mass number1Mass m (default 1). restDelta number— Distance below which the spring may rest (default 0.01, in the value's unit). restSpeed number— Speed below which the spring may rest (default 0.01 units/s). stiffness number170Spring constant k (default 170). Higher is faster. SpringStateinterfaceSpringState
SpringState Prop Type Default Description value(required) number— — velocity(required) number— — TransformLayerinterfaceTransformLayer
Transform composition (contracts/composition.md, ADR 0018 §4). Several effects may move the same element. Instead of each effect writing
transform(last write wins), JavaScript-driven effects contribute *layers* to the element's motion host (host.ts), which writes one composedtransformper frame through its style ledger. CSS-driven effects use the individualtranslate/rotate/scaleproperties, which the browser applies beforetransform, so both kinds coexist without conflicts. Rules (deterministic and independent of layer order): - translations add (px); rotations add per axis (deg); scales multiply (scalewithscaleX/scaleY, Phase 012, additive; written asscale(x, y)only when non-uniform); -perspectivetakes the smallest positive value (the strongest perspective wins); - skews add per axis (deg; Phase 011, additive); - output order: perspective, translate3d, rotateX, rotateY, rotateZ, skew, scale (CSS order); - identity parts are omitted; the identity composition is"none". Summing per-axis rotations is exact for one rotating layer and a close approximation for several small rotations (3D rotations do not commute); documented, not hidden.TransformLayer Prop Type Default Description perspective number— Perspective distance in px (applied first). rotateX number— Degrees. rotateY number— — rotateZ number— — scale number— Uniform scale factor. scaleX number— Horizontal scale factor (Phase 012, multiplies with scale).scaleY number— Vertical scale factor (Phase 012, multiplies with scale).skewX number— Degrees (Phase 011, SP11). skewY number— Degrees (Phase 011, SP11). translateX number— — translateY number— — translateZ number— — TweenControlinterfaceTweenControl
TweenControl Prop Type Default Description cancel(required) () => void— — finish(required) () => void— — finished(required) Promise<MotionResult>— Promise of the current run. pause(required) () => void— — play(required) () => void— — reverse(required) () => void— — seek(required) (progress: number) => void— Set progress in [0, 1] (clamped). From a settled state the control becomes paused in a new run. state(required) MotionState— — AnyEffectDefinitiontypeAnyEffectDefinition
AnyEffectDefinition Prop Type Default Description channels(required) readonly ChannelClaim[]— — family(required) FamilyId— — id(required) EffectId— — policy (options: Resolved) => ReducedMotion | undefined— Reduced-motion policy carried by the options (e.g. Tilt3D's reducedMotionprop).priority number— — reducedMotion(required) ReducedBehaviour— — resolve(required) (options: Options | undefined) => Resolved— Validates options; throw NeshelAnimationsErrorfor invalid input.setup(required) (context: EffectContext<Resolved>) => EffectInstance<Resolved>— — ChannelBindingtypeChannelBinding
ChannelBinding Prop Type Default Description channel(required) "opacity" | "transform" | ExclusiveChannel— — format(required) (value: number) => string— — layer(required) (value: number) => TransformLayer— — ChannelClaimtypeChannelClaim
ChannelClaim Prop Type Default Description channel(required) "transform" | "opacity" | ExclusiveChannel— — mode(required) "compose" | "multiply" | "exclusive"— — ConflictPolicytype"warn" | "error" | "silent"DurationPresettypekeyof typeof motionDefaults.durationEasingtype((t: number) => number) & { readonly css?: string; }EasingPresettypekeyof typeof easingsEffectIdtype`${FamilyId}/${string}`EffectStatetype`failed`: a resumed `setup()` threw; the attachment released everything and reported the error.
"active" | "suspended" | "reduced" | "paused" | "destroyed" | "failed"ExclusiveChanneltype(typeof EXCLUSIVE_CHANNELS)[number] | `--neshel-${string}`FamilyIdtype(typeof FAMILIES)[number]FramePhasetypeFrame scheduler (contracts/core-engine.md §1, ADR 0018 §3). One `requestAnimationFrame` loop shared by every effect. Each frame runs three phases in a fixed order so effects never interleave layout reads with style writes (no layout thrashing): read — measure (getBoundingClientRect, scroll positions) update — advance springs and timelines (pure computation) write — apply styles (transform, custom properties) A task runs once per frame while it returns `true`; returning anything else removes it. Tasks added to a later phase during a frame run in that same frame; tasks added to the current or an earlier phase run in the next frame. The loop stops requesting frames when no task is pending, so an idle page costs nothing. On the server (no `requestAnimationFrame`) scheduling is a no-op.
"read" | "update" | "write"FrameTasktypeReturn `true` to run again on the next frame; any other value (or none) ends the task.
(frame: FrameInfo) => unknownMotionDirectiontype"forward" | "reverse"MotionStatetype"idle" | "running" | "paused" | "completed" | "cancelled" | "interrupted" | "failed"PresetInputtypePresetInput
A definition (default options) or a preset (definition + options).
PresetInput Prop Type Default Description channels(required) readonly ChannelClaim[]— — effect(required) EffectDefinition<Options, Resolved>— — family(required) FamilyId— — id(required) EffectId— — name(required) string— Kebab-case preset name, unique within its effect (e.g. "fade-up").options(required) Readonly<Options>— — policy (options: Resolved) => ReducedMotion | undefined— Reduced-motion policy carried by the options (e.g. Tilt3D's reducedMotionprop).priority number— — reducedMotion(required) ReducedBehaviour— — resolve(required) (options: Options | undefined) => Resolved— Validates options; throw NeshelAnimationsErrorfor invalid input.setup(required) (context: EffectContext<Resolved>) => EffectInstance<Resolved>— — ReducedBehaviourtype"off" | "fade" | "instant" | "static" | "reduced"ReducedMotiontypeReduced-motion policy (contracts/accessibility.md, constitution IV). - `"user"` (default everywhere): follow `prefers-reduced-motion`. - `"always"`: always use the reduced variant (e.g. an application-level "reduce motion" setting). - `"never"`: ignore the preference. Reserved for motion essential to the meaning (WCAG 2.3.3); effects in this package never default to it.
"user" | "always" | "never"SpringPresettypekeyof typeof motionDefaults.springTransitiontypeTransition
Transition Prop Type Default Description delay number— — duration number | DurationPreset— — easing Easing | EasingPreset— — spring SpringOptions | SpringPreset— — type(required) "spring" | "tween"— —