@neshel-ui/animations/core
Todas las exportaciones de @neshel-ui/animations/core, generadas desde sus declaraciones.
Experimental y no disponible en npm
Firmas, miembros y valores por defecto, generados desde las declaraciones compiladas. Las explicaciones y los ejemplos están en la guía.
Las descripciones de esta referencia se generan desde el código fuente del paquete y se muestran en inglés; las guías y el catálogo están en español.
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 Tipo Predeterminado Descripción conflicts ConflictPolicy— — effectId(obligatoria) string— — priority number— — reducedMotion ReducedMotion— — AttachConfiginterfaceAttachConfig
AttachConfig Prop Tipo Predeterminado Descripción conflicts ConflictPolicy— — priority number— Overrides the definition's priority for this attachment. reducedMotion ReducedMotion— Overrides the policy carried by the options. ChannelHandlesinterfaceChannelHandles
ChannelHandles Prop Tipo Predeterminado Descripción exclusive(obligatoria) (channel: ExclusiveChannel) => { set(value: string): void; clear(): void; }— — opacity(obligatoria) { set(value: number): void; clear(): void; }— — transform(obligatoria) { set(layer: TransformLayer): void; clear(): void; }— — ControlOptionsinterfaceControlOptions
ControlOptions Prop Tipo Predeterminado Descripción reducedMotion ReducedMotion— — EffectContextinterfaceEffectContext
EffectContext Prop Tipo Predeterminado Descripción channels(obligatoria) ChannelHandles— — element(obligatoria) Element & { readonly style: CSSStyleDeclaration; }— — onReducedChange(obligatoria) (listener: (reduced: boolean) => void) => () => void— — options(obligatoria) Resolved— — reduced(obligatoria) boolean— Whether motion must be reduced now (live). scheduler(obligatoria) FrameScheduler— — EffectDefinitioninterfaceEffectDefinition
EffectDefinition Prop Tipo Predeterminado Descripción channels(obligatoria) readonly ChannelClaim[]— — family(obligatoria) FamilyId— — id(obligatoria) EffectId— — policy (options: Resolved) => ReducedMotion | undefined— Reduced-motion policy carried by the options (e.g. Tilt3D's reducedMotionprop).priority number— — reducedMotion(obligatoria) ReducedBehaviour— — resolve(obligatoria) (options: Options | undefined) => Resolved— Validates options; throw NeshelAnimationsErrorfor invalid input.setup(obligatoria) (context: EffectContext<Resolved>) => EffectInstance<Resolved>— — EffectHandleinterfaceEffectHandle
EffectHandle Prop Tipo Predeterminado Descripción destroy(obligatoria) () => void— Idempotent; releases channels (restoring styles) and every listener. pause(obligatoria) () => void— — resume(obligatoria) () => void— — state(obligatoria) EffectState— — update(obligatoria) (options?: Options) => void— — EffectInstanceinterfaceEffectInstance
EffectInstance Prop Tipo Predeterminado Descripción destroy(obligatoria) () => void— Must release every listener and frame task it created. pause () => void— — resume () => void— — update(obligatoria) (options: Resolved) => void— — EffectPresetinterfaceEffectPreset
EffectPreset Prop Tipo Predeterminado Descripción effect(obligatoria) EffectDefinition<Options, Resolved>— — name(obligatoria) string— Kebab-case preset name, unique within its effect (e.g. "fade-up").options(obligatoria) Readonly<Options>— — EffectRegistryinterfaceEffectRegistry
EffectRegistry Prop Tipo Predeterminado Descripción get(obligatoria) (id: string) => AnyEffectDefinition | undefined— — has(obligatoria) (id: string) => boolean— — list(obligatoria) (family?: FamilyId) => readonly AnyEffectDefinition[]— — FrameInfointerfaceFrameInfo
FrameInfo Prop Tipo Predeterminado Descripción delta(obligatoria) number— Seconds since the previous frame, clamped to maxDelta(0 on the first frame).time(obligatoria) number— requestAnimationFrametimestamp (ms).FrameSchedulerinterfaceFrameScheduler
FrameScheduler Prop Tipo Predeterminado Descripción schedule(obligatoria) (task: FrameTask, phase?: FramePhase) => () => void"update"Queue taskinphase(default"update"); returns an idempotent cancel function.size(obligatoria) number— Number of pending tasks (diagnostics and tests). FrameSchedulerOptionsinterfaceFrameSchedulerOptions
FrameSchedulerOptions Prop Tipo Predeterminado Descripción maxDelta number— Upper bound of deltain seconds (default 1/15) so a background tab never "jumps".MotionControlinterfaceMotionControl
MotionControl Prop Tipo Predeterminado Descripción cancel(obligatoria) () => void— — finish(obligatoria) () => void— — finished(obligatoria) Promise<MotionResult>— Promise of the current run. pause(obligatoria) () => void— — play(obligatoria) () => void— — reverse(obligatoria) () => void— — state(obligatoria) MotionState— — MotionDebugInfointerfaceMotionDebugInfo
MotionDebugInfo Prop Tipo Predeterminado Descripción channels(obligatoria) Array<{ channel: string; mode: "compose" | "multiply" | "exclusive"; owner?: string; waiting: string[]; contributions: number; }>— — writes(obligatoria) number— — MotionResultinterfaceMotionResult
MotionResult Prop Tipo Predeterminado Descripción direction(obligatoria) MotionDirection— — status(obligatoria) "completed" | "cancelled" | "interrupted"— — value(obligatoria) 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 Tipo Predeterminado Descripción get(obligatoria) () => number— — getVelocity(obligatoria) () => number— — set(obligatoria) (value: number) => void— Set directly (velocity becomes 0); interrupts nothing by itself. subscribe(obligatoria) (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 Tipo Predeterminado Descripción 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 Tipo Predeterminado Descripción value(obligatoria) number— — velocity(obligatoria) 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 Tipo Predeterminado Descripción 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 Tipo Predeterminado Descripción cancel(obligatoria) () => void— — finish(obligatoria) () => void— — finished(obligatoria) Promise<MotionResult>— Promise of the current run. pause(obligatoria) () => void— — play(obligatoria) () => void— — reverse(obligatoria) () => void— — seek(obligatoria) (progress: number) => void— Set progress in [0, 1] (clamped). From a settled state the control becomes paused in a new run. state(obligatoria) MotionState— — AnyEffectDefinitiontypeAnyEffectDefinition
AnyEffectDefinition Prop Tipo Predeterminado Descripción channels(obligatoria) readonly ChannelClaim[]— — family(obligatoria) FamilyId— — id(obligatoria) EffectId— — policy (options: Resolved) => ReducedMotion | undefined— Reduced-motion policy carried by the options (e.g. Tilt3D's reducedMotionprop).priority number— — reducedMotion(obligatoria) ReducedBehaviour— — resolve(obligatoria) (options: Options | undefined) => Resolved— Validates options; throw NeshelAnimationsErrorfor invalid input.setup(obligatoria) (context: EffectContext<Resolved>) => EffectInstance<Resolved>— — ChannelBindingtypeChannelBinding
ChannelBinding Prop Tipo Predeterminado Descripción channel(obligatoria) "opacity" | "transform" | ExclusiveChannel— — format(obligatoria) (value: number) => string— — layer(obligatoria) (value: number) => TransformLayer— — ChannelClaimtypeChannelClaim
ChannelClaim Prop Tipo Predeterminado Descripción channel(obligatoria) "transform" | "opacity" | ExclusiveChannel— — mode(obligatoria) "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 Tipo Predeterminado Descripción channels(obligatoria) readonly ChannelClaim[]— — effect(obligatoria) EffectDefinition<Options, Resolved>— — family(obligatoria) FamilyId— — id(obligatoria) EffectId— — name(obligatoria) string— Kebab-case preset name, unique within its effect (e.g. "fade-up").options(obligatoria) Readonly<Options>— — policy (options: Resolved) => ReducedMotion | undefined— Reduced-motion policy carried by the options (e.g. Tilt3D's reducedMotionprop).priority number— — reducedMotion(obligatoria) ReducedBehaviour— — resolve(obligatoria) (options: Options | undefined) => Resolved— Validates options; throw NeshelAnimationsErrorfor invalid input.setup(obligatoria) (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 Tipo Predeterminado Descripción delay number— — duration number | DurationPreset— — easing Easing | EasingPreset— — spring SpringOptions | SpringPreset— — type(obligatoria) "spring" | "tween"— —