@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
37 lines (36 loc) • 1.61 kB
TypeScript
/**
* Deferred references to the chain of `layoutScroll` ancestors for the
* current subtree. Returned as a thunk because element refs are bound
* after mount; consumers invoke at measurement time.
*
* Order is closest-first. Order doesn't matter for the current scroll-
* offset sum, but is preserved so future per-container semantics (e.g.
* a `scroll.wasRoot` marker like framer-motion) can iterate deterministically.
*/
export type LayoutScrollContainerRef = () => Array<HTMLElement | null | undefined>;
/**
* Publish the scroll-container chain for descendant motion components.
*
* Called on a `motion.*` component with `layoutScroll` enabled during
* its init phase. The provided thunk should resolve to `[...ancestorChain,
* ownElement]` — descendants get the full chain in one call.
*
* Mirrors framer-motion's `removeElementScroll`, which walks the path
* and sums every `layoutScroll` ancestor's offset.
*
* @param ref Thunk returning the full ancestor chain (closest first).
*/
export declare const setLayoutScrollContainer: (ref: LayoutScrollContainerRef) => void;
/**
* Capture the ancestor chain thunk at component init.
*
* Important: call this **before** the same component calls
* `setLayoutScrollContainer(...)`. Otherwise the lookup returns the
* component's own thunk (Svelte `setContext` shadows from the call site
* down) and the chain collapses.
*
* Returns `undefined` when no ancestor has `layoutScroll`.
*
* @returns Ancestor chain thunk, or `undefined`.
*/
export declare const getLayoutScrollContainerRef: () => LayoutScrollContainerRef | undefined;