Skip to content

Svelte 5: flip reordering causes duplication and glitches #9805

@brunnerh

Description

@brunnerh

Describe the bug

Using animate:flip in an #each and completely reordering the list causes duplicated items and a broken animation (elements leaving the bounds of the list and such).

When moving one item to the other end of the list at a time, the animation disappears after having moved all of them. Also, only one item is animated even though all items have to move and thus should be animated.

Not sure how this relates to #9655, which also uses transitions. If this is just a special case, feel free to close this as duplicate.

Reproduction

Svelte 4
Svelte 5


Tried a more simple example where one item gets moved from start of list to the end:

<script>
	import { flip } from 'svelte/animate';

	let items = Array.from({ length: 5 }, (_, i) => ({ id: i, text: `Item ${i+1}` }))

	function update() {
		const [first, ...rest] = items;
		items = [...rest, first];
	}
</script>

<button on:click={update}>Shift</button>
<div class="list">
	{#each items as item (item.id)}
		<div animate:flip>{item.text}</div>
	{/each}
</div>

REPL

Here the animation disappears after cycling through the list once.

Logs

No response

System Info

REPL - Svelte v5.0.0-next.19

Severity

annoyance

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions