Skip to Content
Neshel-UI
Animations (experimental)Reference

@neshel-ui/animations/core

Every export of @neshel-ui/animations/core, generated from its declarations.

Experimental and not on npm

@neshel-ui/animations is a private package (0.0.0). It cannot be installed, and its API may change before a first publication. These pages document what exists in the repository.

Signatures, members and defaults, generated from the built declarations. For explanations and examples read the guide.

  • animateElement function
    (element: Animated, channel: ExclusiveChannel, keyframes: readonly string[], transition: Transition | undefined, options: AnimateElementOptions): TweenControl
  • animateValue function

    Animate a motion value with a spring (default) or a tween; starts immediately.

    (value: MotionValue, target: number, transition?: Transition | undefined, options?: ControlOptions | undefined): MotionControl | TweenControl
  • attachEffect function

    Attach 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>
  • attachPreset function

    Attach 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>
  • bindChannel function

    Write 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; }): () => void
  • composeTransform function
    (layers: Iterable<TransformLayer>): string
  • createEffectRegistry function
    (definitions: readonly AnyEffectDefinition[]): EffectRegistry
  • createFrameScheduler function
    (options?: FrameSchedulerOptions | undefined): FrameScheduler
  • cubicBezier function

    CSS `cubic-bezier()` solved with Newton–Raphson and a bisection fallback (error ≤ 1e-6 in x).

    (x1: number, y1: number, x2: number, y2: number): Easing
  • defineEffect function
    <Options, Resolved>(definition: EffectDefinition<Options, Resolved>): Readonly<EffectDefinition<Options, Resolved>>
  • definePreset function

    Define 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>
  • getFrameScheduler function

    The page-wide scheduler, created on first use (never at import time).

    (): FrameScheduler
  • getMotionDebugInfo function
    (element: object): MotionDebugInfo | undefined
  • mapRange function
    (value: number, inMin: number, inMax: number, outMin: number, outMax: number, options?: { clamp?: boolean | undefined; } | undefined): number
  • motionValue function
    (initial: number): MotionValue
  • prefersReducedMotion function

    Current OS/browser preference; `false` on the server or without `matchMedia`.

    (): boolean
  • resolveSpring function

    Validated, complete options; throws `RangeError` for non-finite or out-of-range values.

    (options?: SpringOptions | undefined): Required<SpringOptions>
  • shouldReduceMotion function

    Whether motion must be reduced for `policy` given the system preference.

    (policy: ReducedMotion, systemPrefersReduced: boolean): boolean
  • springEasing function

    Sample 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; }
  • stepSpring function

    Advance `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): boolean
  • steps function

    CSS `steps(count, jump-start | jump-end)`.

    (count: number, position?: "start" | "end" | undefined): Easing
  • subscribeReducedMotion function

    Call `listener` whenever the preference changes; returns the unsubscribe function.

    (listener: (reduced: boolean) => void): () => void
  • toCssEasing function

    CSS string of a preset or of an easing created by `cubicBezier`/`steps`/`linear`.

    (easing: Easing | "linear" | "standard" | "emphasized" | "decelerate" | "accelerate"): string
  • DEFAULT_SPRING const
    Readonly<Required<SpringOptions>>
  • clamp const

    Pure interpolation helpers (contracts/motion-defaults.md §4).

  • easings const

    Named easings (values tuned in 009 with the lab).

    Readonly<{ linear: Easing; standard: Easing; emphasized: Easing; decelerate: Easing; accelerate: Easing; }>
  • linear const
  • mix const

    Linear interpolation from `from` to `to` at `t` (not clamped).

  • motionDefaults const
    Readonly<{ 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; }>; }>; }>
  • progress const

    Inverse of `mix`: where `value` sits between `from` and `to` (0 when they are equal).

  • NeshelAnimationsError class

    Error thrown for invalid effect usage; identical on the server and the client (ADR 0009 §6).

  • AnimateElementOptions interface

    AnimateElementOptions

    AnimateElementOptions
    PropTypeDefaultDescription
    conflictsConflictPolicy——
    effectId(required)string——
    prioritynumber——
    reducedMotionReducedMotion——
  • AttachConfig interface

    AttachConfig

    AttachConfig
    PropTypeDefaultDescription
    conflictsConflictPolicy——
    prioritynumber—Overrides the definition's priority for this attachment.
    reducedMotionReducedMotion—Overrides the policy carried by the options.
  • ChannelHandles interface

    ChannelHandles

    ChannelHandles
    PropTypeDefaultDescription
    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; }——
  • ControlOptions interface

    ControlOptions

    ControlOptions
    PropTypeDefaultDescription
    reducedMotionReducedMotion——
  • EffectContext interface

    EffectContext

    EffectContext
    PropTypeDefaultDescription
    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——
  • EffectDefinition interface

    EffectDefinition

    EffectDefinition
    PropTypeDefaultDescription
    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 reducedMotion prop).
    prioritynumber——
    reducedMotion(required)ReducedBehaviour——
    resolve(required)(options: Options | undefined) => Resolved—Validates options; throw NeshelAnimationsError for invalid input.
    setup(required)(context: EffectContext<Resolved>) => EffectInstance<Resolved>——
  • EffectHandle interface

    EffectHandle

    EffectHandle
    PropTypeDefaultDescription
    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——
  • EffectInstance interface

    EffectInstance

    EffectInstance
    PropTypeDefaultDescription
    destroy(required)() => void—Must release every listener and frame task it created.
    pause() => void——
    resume() => void——
    update(required)(options: Resolved) => void——
  • EffectPreset interface

    EffectPreset

    EffectPreset
    PropTypeDefaultDescription
    effect(required)EffectDefinition<Options, Resolved>——
    name(required)string—Kebab-case preset name, unique within its effect (e.g. "fade-up").
    options(required)Readonly<Options>——
  • EffectRegistry interface

    EffectRegistry

    EffectRegistry
    PropTypeDefaultDescription
    get(required)(id: string) => AnyEffectDefinition | undefined——
    has(required)(id: string) => boolean——
    list(required)(family?: FamilyId) => readonly AnyEffectDefinition[]——
  • FrameInfo interface

    FrameInfo

    FrameInfo
    PropTypeDefaultDescription
    delta(required)number—Seconds since the previous frame, clamped to maxDelta (0 on the first frame).
    time(required)number—requestAnimationFrame timestamp (ms).
  • FrameScheduler interface

    FrameScheduler

    FrameScheduler
    PropTypeDefaultDescription
    schedule(required)(task: FrameTask, phase?: FramePhase) => () => void"update"Queue task in phase (default "update"); returns an idempotent cancel function.
    size(required)number—Number of pending tasks (diagnostics and tests).
  • FrameSchedulerOptions interface

    FrameSchedulerOptions

    FrameSchedulerOptions
    PropTypeDefaultDescription
    maxDeltanumber—Upper bound of delta in seconds (default 1/15) so a background tab never "jumps".
  • MotionControl interface

    MotionControl

    MotionControl
    PropTypeDefaultDescription
    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——
  • MotionDebugInfo interface

    MotionDebugInfo

    MotionDebugInfo
    PropTypeDefaultDescription
    channels(required)Array<{ channel: string; mode: "compose" | "multiply" | "exclusive"; owner?: string; waiting: string[]; contributions: number; }>——
    writes(required)number——
  • MotionResult interface

    MotionResult

    MotionResult
    PropTypeDefaultDescription
    direction(required)MotionDirection——
    status(required)"completed" | "cancelled" | "interrupted"——
    value(required)number—Final value (JS driver) or progress 0–1 (WAAPI driver).
  • MotionValue interface

    MotionValue

    Motion values: numbers that animate without React state (contracts/controllers.md §3).

    MotionValue
    PropTypeDefaultDescription
    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.
  • SpringOptions interface

    SpringOptions

    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
    PropTypeDefaultDescription
    dampingnumber26Damping coefficient c (default 26). c >= 2 * sqrt(k * m) never overshoots.
    massnumber1Mass m (default 1).
    restDeltanumber—Distance below which the spring may rest (default 0.01, in the value's unit).
    restSpeednumber—Speed below which the spring may rest (default 0.01 units/s).
    stiffnessnumber170Spring constant k (default 170). Higher is faster.
  • SpringState interface

    SpringState

    SpringState
    PropTypeDefaultDescription
    value(required)number——
    velocity(required)number——
  • TransformLayer interface

    TransformLayer

    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 composed transform per frame through its style ledger. CSS-driven effects use the individual translate / rotate / scale properties, which the browser applies before transform, so both kinds coexist without conflicts. Rules (deterministic and independent of layer order): - translations add (px); rotations add per axis (deg); scales multiply (scale with scaleX/scaleY, Phase 012, additive; written as scale(x, y) only when non-uniform); - perspective takes 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
    PropTypeDefaultDescription
    perspectivenumber—Perspective distance in px (applied first).
    rotateXnumber—Degrees.
    rotateYnumber——
    rotateZnumber——
    scalenumber—Uniform scale factor.
    scaleXnumber—Horizontal scale factor (Phase 012, multiplies with scale).
    scaleYnumber—Vertical scale factor (Phase 012, multiplies with scale).
    skewXnumber—Degrees (Phase 011, SP11).
    skewYnumber—Degrees (Phase 011, SP11).
    translateXnumber——
    translateYnumber——
    translateZnumber——
  • TweenControl interface

    TweenControl

    TweenControl
    PropTypeDefaultDescription
    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——
  • AnyEffectDefinition type

    AnyEffectDefinition

    AnyEffectDefinition
    PropTypeDefaultDescription
    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 reducedMotion prop).
    prioritynumber——
    reducedMotion(required)ReducedBehaviour——
    resolve(required)(options: Options | undefined) => Resolved—Validates options; throw NeshelAnimationsError for invalid input.
    setup(required)(context: EffectContext<Resolved>) => EffectInstance<Resolved>——
  • ChannelBinding type

    ChannelBinding

    ChannelBinding
    PropTypeDefaultDescription
    channel(required)"opacity" | "transform" | ExclusiveChannel——
    format(required)(value: number) => string——
    layer(required)(value: number) => TransformLayer——
  • ChannelClaim type

    ChannelClaim

    ChannelClaim
    PropTypeDefaultDescription
    channel(required)"transform" | "opacity" | ExclusiveChannel——
    mode(required)"compose" | "multiply" | "exclusive"——
  • ConflictPolicy type
    "warn" | "error" | "silent"
  • DurationPreset type
    keyof typeof motionDefaults.duration
  • Easing type
    ((t: number) => number) & { readonly css?: string; }
  • EasingPreset type
    keyof typeof easings
  • EffectId type
    `${FamilyId}/${string}`
  • EffectState type

    `failed`: a resumed `setup()` threw; the attachment released everything and reported the error.

    "active" | "suspended" | "reduced" | "paused" | "destroyed" | "failed"
  • ExclusiveChannel type
    (typeof EXCLUSIVE_CHANNELS)[number] | `--neshel-${string}`
  • FamilyId type
    (typeof FAMILIES)[number]
  • FramePhase type

    Frame 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"
  • FrameTask type

    Return `true` to run again on the next frame; any other value (or none) ends the task.

    (frame: FrameInfo) => unknown
  • MotionDirection type
    "forward" | "reverse"
  • MotionState type
    "idle" | "running" | "paused" | "completed" | "cancelled" | "interrupted" | "failed"
  • PresetInput type

    PresetInput

    A definition (default options) or a preset (definition + options).

    PresetInput
    PropTypeDefaultDescription
    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 reducedMotion prop).
    prioritynumber——
    reducedMotion(required)ReducedBehaviour——
    resolve(required)(options: Options | undefined) => Resolved—Validates options; throw NeshelAnimationsError for invalid input.
    setup(required)(context: EffectContext<Resolved>) => EffectInstance<Resolved>——
  • ReducedBehaviour type
    "off" | "fade" | "instant" | "static" | "reduced"
  • ReducedMotion type

    Reduced-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"
  • SpringPreset type
    keyof typeof motionDefaults.spring
  • Transition type

    Transition

    Transition
    PropTypeDefaultDescription
    delaynumber——
    durationnumber | DurationPreset——
    easingEasing | EasingPreset——
    springSpringOptions | SpringPreset——
    type(required)"spring" | "tween"——
Edit on GitHub