Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/transition-direction-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'svelte-check': patch
'svelte2tsx': patch
---

fix: allow transitions to return a function taking a `direction` argument
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
) {
return {};
}

function deferredTransition(
_node: HTMLElement,
_params: { delay: number },
_context: { direction: 'in' | 'out' | 'both' }
) {
return (_options: { direction: 'in' | 'out' }) => ({ delay: 100 });
}
</script>

<div in:myTransition={{ delay: 100 }} />
<div in:deferredTransition={{ delay: 100 }} />
4 changes: 2 additions & 2 deletions packages/svelte2tsx/svelte-shims-v4.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type SvelteTransitionConfig = {
}

/** @internal PRIVATE API, DO NOT USE */
type SvelteTransitionReturnType = SvelteTransitionConfig | (() => SvelteTransitionConfig)
type SvelteTransitionReturnType = SvelteTransitionConfig | ((options: { direction: 'in' | 'out' }) => SvelteTransitionConfig)

/** @internal PRIVATE API, DO NOT USE */
type SvelteAnimationReturnType = {
Expand Down Expand Up @@ -173,7 +173,7 @@ type __sveltets_2_SvelteTransitionConfig = {
tick?: (t: number, u: number) => void
}
/** @internal PRIVATE API, DO NOT USE */
type __sveltets_2_SvelteTransitionReturnType = __sveltets_2_SvelteTransitionConfig | (() => __sveltets_2_SvelteTransitionConfig)
type __sveltets_2_SvelteTransitionReturnType = __sveltets_2_SvelteTransitionConfig | ((options: { direction: 'in' | 'out' }) => __sveltets_2_SvelteTransitionConfig)
declare function __sveltets_2_ensureTransition(transitionCall: __sveltets_2_SvelteTransitionReturnType): {};

// Includes undefined and null for all types as all usages also allow these
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte2tsx/svelte-shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type SvelteTransitionConfig = {
}

/** @internal PRIVATE API, DO NOT USE */
type SvelteTransitionReturnType = SvelteTransitionConfig | (() => SvelteTransitionConfig)
type SvelteTransitionReturnType = SvelteTransitionConfig | ((options: { direction: 'in' | 'out' }) => SvelteTransitionConfig)

/** @internal PRIVATE API, DO NOT USE */
type SvelteAnimationReturnType = {
Expand Down Expand Up @@ -253,7 +253,7 @@ type __sveltets_2_SvelteTransitionConfig = {
tick?: (t: number, u: number) => void
}
/** @internal PRIVATE API, DO NOT USE */
type __sveltets_2_SvelteTransitionReturnType = __sveltets_2_SvelteTransitionConfig | (() => __sveltets_2_SvelteTransitionConfig)
type __sveltets_2_SvelteTransitionReturnType = __sveltets_2_SvelteTransitionConfig | ((options: { direction: 'in' | 'out' }) => __sveltets_2_SvelteTransitionConfig)
declare function __sveltets_2_ensureTransition(transitionCall: __sveltets_2_SvelteTransitionReturnType): {};

// Includes undefined and null for all types as all usages also allow these
Expand Down