From 384783103db15fd0676054eb4505413e6ae89f27 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 8 Apr 2025 21:26:23 -0400 Subject: [PATCH] switch order --- .../docs/03-template-syntax/13-transition.md | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/documentation/docs/03-template-syntax/13-transition.md b/documentation/docs/03-template-syntax/13-transition.md index d62884b93c..c51175c272 100644 --- a/documentation/docs/03-template-syntax/13-transition.md +++ b/documentation/docs/03-template-syntax/13-transition.md @@ -4,24 +4,6 @@ title: transition: A _transition_ is triggered by an element entering or leaving the DOM as a result of a state change. - Transitions are _local_ by default. Local transitions only play when the block they belong to is created or destroyed, _not_ when parent blocks are created or destroyed. - -## Global Transitions - -You can specify a _global_ transition should by appending the modifier `|global` to the directive. - -```svelte -{#if x} - {#if y} -

fades in and out only when y changes

- -

fades in and out when x or y change

- {/if} -{/if} -``` - -## Bidirectional Transitions - When a block (such as an `{#if ...}` block) is transitioning out, all elements inside it, including those that do not have their own transitions, are kept in the DOM until every transition in the block has been completed. The `transition:` directive indicates a _bidirectional_ transition, which means it can be smoothly reversed while the transition is in progress. @@ -40,11 +22,24 @@ The `transition:` directive indicates a _bidirectional_ transition, which means {/if} ``` +## Local vs global + +Transitions are local by default. Local transitions only play when the block they belong to is created or destroyed, _not_ when parent blocks are created or destroyed. + +```svelte +{#if x} + {#if y} +

fades in and out only when y changes

+ +

fades in and out when x or y change

+ {/if} +{/if} +``` + ## Built-in transitions A selection of built-in transitions can be imported from the [`svelte/transition`](svelte-transition) module. - ## Transition parameters Transitions can have parameters.