weasel API - v0.8.0
    Preparing search index...

    Interface Animator

    interface Animator {
        colorOverrides: ColorOverrideRegistry;
        cancel(handle: AnimationHandle): void;
        cancelAll(): void;
        cancelKey(key: string): void;
        decay<T>(opts: DecayOptions<T>): AnimationHandle;
        isActive(key?: string): boolean;
        isPaused(): boolean;
        isTicking(): boolean;
        keepAlive(): () => void;
        loop(factory: LoopFactory, opts?: LoopOptions): AnimationHandle;
        onTick(cb: () => void): () => void;
        pause(): void;
        pauseKey(key: string): void;
        physics<T>(opts: PhysicsOptions<T>): PhysicsHandle<T>;
        resume(): void;
        resumeKey(key: string): void;
        setTimeScale(scale: number): void;
        setTimeScaleByKey(key: string, scale: number): void;
        spring<T>(opts: SpringOptions<T>): AnimationHandle;
        stagger<TItem>(
            items: readonly TItem[],
            delay: StaggerDelay,
        ): StaggerBuilder<TItem>;
        stagger<TItem>(
            items: readonly TItem[],
            delay: StaggerDelay,
            factory: StaggerFactory<TItem>,
            opts?: StaggerOptions,
        ): AnimationHandle;
        tween<T>(opts: TweenOptions<T>): AnimationHandle;
        tweenLoop<T>(opts: TweenLoopOptions<T>): AnimationHandle;
    }
    Index

    Properties

    colorOverrides: ColorOverrideRegistry

    Per-node, per-channel color override registry consulted by the renderer's path layer before reading consumer accessors. Used by tweenVertexColors, springVertexColors, cycleVertexColors, staggerVertexColors. Cleared automatically on animator unmount.

    Methods

    • True iff at least one animation is active. With key, scoped to that cancelKey.

      Parameters

      • Optionalkey: string

      Returns boolean

    • True while the animator is currently executing an animation tick. Useful for adapter wrappers (e.g. animateOnSetPose) that need to detect "this setPose was called from inside another animation's onTick" (momentum decay, in-flight tween, spring) and avoid recursively scheduling a new wrap-animation that would fight the caller.

      Returns boolean

    • Keep the animator's RAF loop running until the returned cancel function is called. Use for animations whose effect is read on every frame but which don't have a natural progress state (e.g. cycleVertexColors, which expresses its current value as a function of performance.now() rather than as a tween from from to to). Without a keep-alive entry the loop would idle and onTick would stop firing even though the override is still installed.

      Returns () => void

    • Loop primitive: repeatedly invoke factory to produce a child animation. The factory must wire its returned handle's onDone to call next so the loop advances. Returns a handle whose pause/resume/setTimeScale/cancel delegate to the current in-flight child (and prevent future iterations on cancel).

      The loop is registered with the animator under a supervisor entry so animator.cancel(handle), animator.cancelKey(opts.cancelKey), and animator.isActive(opts.cancelKey) all work for it.

      Parameters

      Returns AnimationHandle

    • Subscribe to a callback fired once per RAF frame while any animation is active. Returns an unsubscribe function. Used by consumers (typically <SceneCanvas>) that need to repaint when an animation's side-effect is read from a non-scene channel (e.g. colorOverrides consulted from a custom drawOne) — scene mutations naturally trigger a repaint, but colorOverrides writes do not.

      The callback fires AFTER the per-frame tick of each registered animation, so by the time it runs colorOverrides.get(...) returns the latest values. If no animations are active, no tick fires.

      Parameters

      • cb: () => void

      Returns () => void

    • Set per-animation timeScale for every animation whose cancelKey matches.

      Parameters

      • key: string
      • scale: number

      Returns void