@humanspeak/svelte-motion
Version:
Framer Motion for Svelte 5. Declarative motion.<tag> components with AnimatePresence exit animations, gestures (hover, tap, drag, focus, in-view), variants, FLIP layout animations, shared-layout transitions, spring physics, and scroll-linked motion values
46 lines (45 loc) • 1.84 kB
TypeScript
import { type AnimationOptions } from 'motion';
/**
* Split a focus definition into keyframes and an optional nested transition.
*
* @param def While-focus record that may include a nested `transition`.
* @returns Object with `keyframes` (no `transition`) and optional `transition`.
*/
export declare const splitFocusDefinition: (def: Record<string, unknown>) => {
keyframes: Record<string, unknown>;
transition?: AnimationOptions;
};
/**
* Compute the baseline values to restore to on focus end.
*
* Preference order per key: `animate` → `initial` → neutral transform defaults.
*
* @param el Target element.
* @param opts Source records for baseline computation.
* @returns Minimal baseline record to restore on focus end.
*/
export declare const computeFocusBaseline: (el: HTMLElement, opts: {
initial?: Record<string, unknown>;
animate?: Record<string, unknown>;
whileFocus?: Record<string, unknown>;
}) => Record<string, unknown>;
/**
* Attach whileFocus interactions to an element.
*
* On focus, animates to `whileFocus` (using nested `transition` if provided).
* On blur, restores changed keys to the baseline using the merged transition.
*
* @param el Target element.
* @param whileFocus While-focus definition.
* @param mergedTransition Root/component merged transition.
* @param callbacks Optional lifecycle callbacks for focus start/end.
* @param baselineSources Optional sources used to compute baseline.
* @returns Cleanup function to remove listeners.
*/
export declare const attachWhileFocus: (el: HTMLElement, whileFocus: Record<string, unknown> | undefined, mergedTransition: AnimationOptions, callbacks?: {
onStart?: () => void;
onEnd?: () => void;
}, baselineSources?: {
initial?: Record<string, unknown>;
animate?: Record<string, unknown>;
}) => (() => void);