@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
21 lines (20 loc) • 709 B
JavaScript
/**
* Extracts keyframes from the initial prop, handling the `initial={false}` case.
*
* When `initial={false}`, the element should skip its initial animation and
* render directly at its animated state. This function returns `undefined` for
* `initial={false}`, and the keyframes object otherwise.
*
* @param initial - The initial prop value
* @returns Keyframes to apply, or undefined
*
* @example
* ```typescript
* getInitialKeyframes({ opacity: 0 }) // { opacity: 0 }
* getInitialKeyframes(false) // undefined
* getInitialKeyframes(undefined) // undefined
* ```
*/
export const getInitialKeyframes = (initial) => {
return initial === false ? undefined : initial;
};