@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
20 lines (19 loc) • 647 B
JavaScript
import { getContext, setContext } from 'svelte';
const key = Symbol('motionConfig');
/**
* Retrieve the current motion configuration from Svelte component context.
*
* @returns The active `MotionConfigProps`, or `undefined` if none was set by a parent.
*/
export const getMotionConfig = () => {
return getContext(key);
};
/**
* Provide motion configuration to descendant components via Svelte context.
*
* @param motionConfig The configuration to propagate (e.g. `transition`).
* @returns The same `MotionConfigProps` that was set.
*/
export const createMotionConfig = (motionConfig) => {
return setContext(key, motionConfig);
};