import type { ReactiveController, ReactiveControllerHost } from 'lit'; /** Fill mode for WAAPI (KeyframeEffectOptions). */ export type FillMode = 'none' | 'forwards' | 'backwards' | 'both'; /** Playback direction for WAAPI (KeyframeEffectOptions). */ export type AnimationDirection = 'normal' | 'reverse' | 'alternate' | 'alternate-reverse'; /** * Options for a single animation run (Web Animations API). * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options */ export interface AnimationOptions { /** Duration in milliseconds. */ duration?: number; /** Delay before start in milliseconds. */ delay?: number; /** Easing function (CSS easing or cubic-bezier). */ easing?: string; /** Fill mode: 'none' | 'forwards' | 'backwards' | 'both'. */ fill?: FillMode; /** Number of iterations (default 1). */ iterations?: number; /** Playback direction. */ direction?: AnimationDirection; /** End delay in milliseconds. */ endDelay?: number; /** Unique id for the animation (useful for canceling by id). */ id?: string; } /** * Keyframes format accepted by Element.animate(). * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats */ export type AnimationKeyframes = Keyframe[] | PropertyIndexedKeyframes; /** * Configuration for the controller defaults (used when not overridden per call). */ export interface AnimationControllerConfig { defaultDuration?: number; defaultEasing?: string; defaultFill?: FillMode; } /** Direction for slide presets. */ export type SlideDirection = 'up' | 'down' | 'left' | 'right'; /** * AnimationController – consistent animations via the Web Animations API (WAAPI). * * Use as a Lit ReactiveController so components get: * - Shared defaults (duration, easing, fill) * - Preset helpers: fadeIn, fadeOut, slideIn, slideOut, scaleIn, scaleOut * - Low-level animate() for custom keyframes * - Automatic cancellation of running animations when the host disconnects * * @example * ```ts * class MyPanel extends LitElement { * animation = new AnimationController(this, { defaultDuration: 200, defaultEasing: 'ease-out' }); * * async open() { * await this.animation.fadeIn(this.panelEl); * } * * async close() { * await this.animation.fadeOut(this.panelEl); * } * } * ``` */ export declare class AnimationController implements ReactiveController { readonly host: ReactiveControllerHost; private readonly config; private readonly running; constructor(host: ReactiveControllerHost, config?: AnimationControllerConfig); hostDisconnected(): void; /** * Run a WAAPI animation on an element. Returns the Animation for chaining or await .finished. * Running animations are tracked and cancelled when the host disconnects. */ animate(element: Element | null | undefined, keyframes: AnimationKeyframes, options?: AnimationOptions): Animation | null; /** * Fade in: opacity 0 → 1. */ fadeIn(element: Element | null | undefined, options?: AnimationOptions): Animation | null; /** * Fade out: opacity 1 → 0. */ fadeOut(element: Element | null | undefined, options?: AnimationOptions): Animation | null; /** * Slide in from the given direction (translate from off-screen to 0). */ slideIn(element: Element | null | undefined, options?: AnimationOptions & { direction?: SlideDirection; }): Animation | null; /** * Slide out toward the given direction (translate from 0 to off-screen). */ slideOut(element: Element | null | undefined, options?: AnimationOptions & { direction?: SlideDirection; }): Animation | null; /** * Scale in: scale(0) or scale(0.9) → scale(1). Optionally combine with opacity. */ scaleIn(element: Element | null | undefined, options?: AnimationOptions & { fromScale?: number; opacity?: boolean; }): Animation | null; /** * Scale out: scale(1) → scale(0.95) or custom. Optionally combine with opacity. */ scaleOut(element: Element | null | undefined, options?: AnimationOptions & { toScale?: number; opacity?: boolean; }): Animation | null; /** * Cancel a specific animation (e.g. one you stored from animate() or a preset). */ cancel(animation: Animation): void; /** * Cancel all animations currently running for this controller. */ cancelAll(): void; }