Describe the bug
When using transitions like fly in combination with the flip animation, the transitions can be adversely affected.
- When multiple transitions are activated at the same time, previous transitions can stutter and end up transitioning to the wrong location. After the transitions has finished the elements will snap into the correct place, however.
- Adjacent elements that transition out at the same time, will collapse into the same position and outro from there. E.g. three items will all outro from the position of the first item. (This issue already exists in Svelte 4, though.)
Reproduction
Code
<script>
import { fly } from 'svelte/transition';
import { flip } from 'svelte/animate';
let items = $state([]);
let i = $state(0);
const add = () => items.push(i++, i++, i++, i++);
const del = () => items = items.filter(i => i % 4 == 0);
const options = {
x: 200,
duration: 1000,
};
add();add();add();
</script>
<button onclick={add}>Add</button>
<button onclick={del}>Delete Some</button>
<button onclick={() => items = []}>Delete All</button>
<div class="grid">
<div>
<h2>Without FLIP</h2>
{#each items as i (i)}
<div transition:fly={options}>{i}</div>
{/each}
</div>
<div>
<h2>With FLIP</h2>
{#each items as i (i)}
<div transition:fly={options} animate:flip>{i}</div>
{/each}
</div>
</div>
<style>
:global(html) { overflow: clip; }
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 32px;
}
</style>
Svelte 4
Svelte 5
- For the intro transition issues, click "Add" several times in quick succession, so other items are still transitioning while adding new ones. This issue does not appear to happen in Svelte 4.
- For the outro transition overlapping, use one of the delete actions. The button that only deletes some items shows how items collapse into groups. This should also happen in Svelte 4.
Logs
No response
System Info
REPL - Svelte v5.0.0-next.37
Chrome and Firefox
Severity
annoyance
Describe the bug
When using transitions like
flyin combination with theflipanimation, the transitions can be adversely affected.Reproduction
Code
Svelte 4
Svelte 5
Logs
No response
System Info
Severity
annoyance