UNPKG

@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

19 lines (18 loc) 696 B
import { getContext, setContext } from 'svelte'; const MOTION_DOM_PROJECTION_CONTEXT_KEY = Symbol('svelte-motion:motion-dom-projection-parent'); /** * Publish the current upstream motion-dom projection adapter to descendants. * * @param node Current component projection adapter, or `null` to clear. */ export const setMotionDomProjectionParent = (node) => { setContext(MOTION_DOM_PROJECTION_CONTEXT_KEY, node); }; /** * Read the nearest upstream motion-dom projection adapter. * * @returns Parent projection adapter, or `null` when no motion ancestor exists. */ export const getMotionDomProjectionParent = () => { return getContext(MOTION_DOM_PROJECTION_CONTEXT_KEY) ?? null; };