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

33 lines (32 loc) 898 B
/** * Module-level singleton registry shared across the entire component tree. * This matches React Framer Motion's behavior where layoutId is shared globally * (or within a LayoutGroup, which we can add later). */ const entries = new Map(); export const layoutIdRegistry = { snapshot(id, rect, transition) { entries.set(id, { rect, transition }); }, consume(id) { const entry = entries.get(id); if (entry) entries.delete(id); return entry; } }; /** * Get the global layoutId registry. * * @returns The singleton `LayoutIdRegistry` instance. * * @example * ```ts * const registry = getLayoutIdRegistry() * registry.snapshot('hero', element.getBoundingClientRect()) * const entry = registry.consume('hero') // one-shot: returns and deletes * ``` */ export const getLayoutIdRegistry = () => { return layoutIdRegistry; };