I was following the Svelte tutorial, more specifically the part about REST params, I tried to animate the whole thing; however, I only succeeded into animating what is inside the each block.
I wanted to use animate:flip on the <p> below the each block but it's not possible since it can only be used on direct children of the previously mentioned block.
My question is, how can I animate the change of position like animate:flip would've done?
For reference, here's the code that I modified in the tutorial.
<div class="flex">
{#each words.slice(0, depth) as word (word)}
<p animate:flip transition:fade>{word}</p>
{/each}
<p><a href={next}>{words[depth] ?? '?'}</a></p> <!-- I'd like to animate this -->
</div>
P.S.: Sorry if it's an already answered question but I can't find any proper way of doing so online.
You could make the last element part of the each, that way the animation will be applied, e.g.
(Not looping over
words.sliceso it can read over the bounds for parity with the example. Otherwise you would never get a?entry.)