UNPKG

@ssgoi/svelte

Version:

Svelte bindings for SSGOI - Native app-like page transitions for Svelte and SvelteKit applications

34 lines (33 loc) 1.12 kB
import { transition as _transition, } from "@ssgoi/core"; /** * Svelte action for element transitions * * Uses Svelte's destroy callback for OUT transition detection. * This ensures the correct transition config is used even when * params are updated (e.g., during SvelteKit page navigation). */ export var transition = function (node, params) { var callback = _transition({ key: params.key, in: params.in, out: params.out, scope: params.scope, }); var cleanup = callback(node); return { update: function (newParams) { callback = _transition({ key: newParams.key, in: newParams.in, out: newParams.out, scope: newParams.scope, }); cleanup = callback(node); }, destroy: function () { // Call cleanup to trigger OUT transition with the correct config // The cleanup function captures the transition config at registration time cleanup === null || cleanup === void 0 ? void 0 : cleanup(); }, }; };