import type { AtomType } from "../Mutables/atom/atom"; /** * Keyframe definition — maps directly to the Web Animations API `Keyframe` type. */ export type AnimateKeyframes = Keyframe[] | PropertyIndexedKeyframes; /** * Animation timing options — maps to `KeyframeAnimationOptions` from the * Web Animations API, with sensible defaults layered on top. */ export interface AnimateOptions extends KeyframeAnimationOptions { /** Duration in milliseconds. Defaults to 300. */ duration?: number; /** CSS easing string. Defaults to "ease". */ easing?: string; /** Fill mode. Defaults to "both". */ fill?: FillMode; } /** * How to supply the target element — directly, via a Ref, or via a lazy getter. */ export type ElementTarget = Element | { value?: Element | undefined; } | (() => Element | null | undefined); /** * The handle returned by `animate()`. * * A lightweight, stateful animation controller backed by the Web Animations API. * Only exposes what you need: start/stop controls, a single reactive `isRunning` * atom, and re-configuration helpers. * * @example * ```ts * const { start, stop, isRunning } = animate( * boxRef, * [{ opacity: 0 }, { opacity: 1 }], * { duration: 400 }, * () => console.log("started"), * () => console.log("ended"), * ); * * start(); // plays (cancels any previous run) * stop(); // cancels entirely * isRunning(); // true while playing * pause(); * resume(); * reverse(); * finish(); // jumps to end state * ``` */ export interface AnimationHandle { /** Play the animation. Auto-cancels any in-flight run. */ start: () => void; /** Cancel the animation entirely. */ stop: () => void; /** Pause a running animation. */ pause: () => void; /** Resume a paused animation. */ resume: () => void; /** Reverse the playback direction. */ reverse: () => void; /** Jump to the end state immediately. */ finish: () => void; /** Atom: `true` while the animation is running. */ isRunning: AtomType; /** The current Web Animations API `Animation` instance, or `null` if idle. */ readonly currentAnimation: Animation | null; /** The current playback state of the underlying animation. */ readonly playState: AnimationPlayState | "idle"; /** Replace the target element after creation. */ setElement: (el: ElementTarget) => void; /** Replace the keyframes after creation. */ setKeyframes: (keyframes: AnimateKeyframes) => void; /** Merge new options into the current options. */ setOptions: (options: AnimateOptions) => void; } /** * Configuration for the `animateDirective` lit-html directive. */ export interface AnimateDirectiveConfig { /** Keyframes to animate */ keyframes: AnimateKeyframes; /** Animation options (duration, easing, fill, etc.) */ options?: AnimateOptions; /** * When true, the animation plays immediately when the directive * is first applied or when this value transitions from false→true. * Defaults to true. */ play?: boolean; /** Callback fired when the animation starts. */ onStart?: () => void; /** Callback fired when the animation ends (finished or cancelled). */ onEnd?: () => void; } /** * Preset animation factories — convenience functions that return * `{ keyframes, options }` pairs ready to spread into `animate()`. */ export interface AnimationPreset { keyframes: AnimateKeyframes; options: AnimateOptions; } //# sourceMappingURL=animateTypes.d.ts.map