import type { AnimationPreset } from "./animateTypes"; /** * Animate an element with a given preset. Cancels any in-flight * animations on the element first. * * Returns a promise that resolves when the animation finishes or is cancelled. */ export declare function animateContainer(el: HTMLElement, preset: AnimationPreset): Promise; /** * Wait two animation frames so lit-html has committed any pending * template updates to the DOM before we read element geometry or * start a new animation. */ export declare function nextFrame(): Promise; /** * Configuration for a single `animateSwap` call. */ export interface AnimateSwapConfig { /** * The wrapper element to animate. * When `null`/`undefined`, the swap runs immediately with no animation. */ el: HTMLElement | null | undefined; /** Animation preset played on the wrapper *before* the swap. */ exit: AnimationPreset; /** Animation preset played on the wrapper *after* the swap. */ enter: AnimationPreset; /** * Called between exit and enter — this is where you update the atom / * state that drives what is rendered inside the wrapper. */ swap: () => void; /** * Optional: re-resolve the wrapper element after the swap. * Useful when the swap replaces the wrapper itself (e.g. a new `
` * rendered by lit-html). When omitted the original `el` is reused. */ getEl?: () => HTMLElement | null | undefined; /** * Optional staleness guard. Called after exit and after swap — if it * returns `true` the sequence aborts early. Use this to bail out when * a newer swap has been requested while this one was in flight. * * @example * ```ts * isStale: () => nextRoute.get() !== targetRoute * ``` */ isStale?: () => boolean; } /** * Orchestrates the exit → swap → enter animation sequence. * * 1. Play `exit` on `el`. * 2. Call `swap()` — the caller updates state so the template re-renders. * 3. Wait one double-rAF (`nextFrame`) so lit-html commits the new DOM. * 4. Play `enter` on the (possibly new) wrapper element. * * At steps 2 and 4 the optional `isStale()` guard is checked — if it * returns `true` the sequence stops, letting a newer transition take over. * * If `el` is `null`/`undefined`, steps 1 and 3–4 are skipped and * `swap()` is called immediately. * * @example * ```ts * // Inside an effect that watches `nextRoute`: * await animateSwap({ * el: wrapperRef.value, * exit: current?.exit ?? animationPresets.fadeOut(200), * enter: next?.enter ?? animationPresets.fadeIn(250), * swap: () => currentRoute.set(next), * getEl: () => wrapperRef.value, * isStale: () => nextRoute.get() !== next, * }); * ``` */ export declare function animateSwap(config: AnimateSwapConfig): Promise; //# sourceMappingURL=animateSwap.d.ts.map