Skip to content
Discussion options

You must be logged in to vote

Add the |local modifier to your transition: https://svelte.dev/docs#template-syntax-element-directives-transition-fn-transition-events

Local transitions only play when the block they belong to is created or destroyed, not when parent blocks are created or destroyed.

{#if x}
	{#if y}
		<p transition:fade>
			fades in and out when x or y change
		</p>

		<p transition:fade|local>
			fades in and out only when y changes
		</p>
	{/if}
{/if}

There's an issue about making this the default behavior in Svelte 4.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Glench
Comment options

Answer selected by Glench
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants