Consider a Svelte component that uses the flip animation on a list of items. What is the visible effect when the list order changes?
<script> import { flip } from 'svelte/animate'; let items = ['A', 'B', 'C']; function reorder() { items = ['C', 'A', 'B']; } </script> <ul> {#each items as item (item)} <li animate:flip>{item}</li> {/each} </ul> <button on:click={reorder}>Reorder</button>
Think about what the FLIP technique is designed to do: it animates position changes smoothly.
The FLIP animation in Svelte animates elements moving from their old position to their new position smoothly, creating a sliding effect when list items reorder.
Choose the correct syntax to apply the FLIP animation to each item in a Svelte list.
<script> import { flip } from 'svelte/animate'; let items = [1, 2, 3]; </script> <ul> {#each items as item (item)} <!-- Which line correctly applies flip animation? --> <li>...</li> {/each} </ul>
Remember that FLIP is an animation, not a transition or action.
In Svelte, the FLIP animation is applied using animate:flip directive on elements that change position.
Given this Svelte list with FLIP animation, why does the animation not trigger when reordering?
<script> import { flip } from 'svelte/animate'; let items = ['x', 'y', 'z']; function shuffle() { items = ['z', 'x', 'y']; } </script> <ul> {#each items as item} <li animate:flip>{item}</li> {/each} </ul> <button on:click={shuffle}>Shuffle</button>
Think about how Svelte tracks elements in a list for animations.
Svelte needs unique keys in the {#each} block to track elements and animate their position changes with FLIP. Without keys, it cannot detect moves.
Given this Svelte component, what is the order of items displayed after clicking the button twice?
<script> import { flip } from 'svelte/animate'; let items = ['1', '2', '3']; function rotate() { items = [...items.slice(1), items[0]]; } </script> <ul> {#each items as item (item)} <li animate:flip>{item}</li> {/each} </ul> <button on:click={rotate}>Rotate</button>
Each click moves the first item to the end. Think step by step.
First click: ['2', '3', '1']
Second click: ['3', '1', '2']
Choose the best explanation for why FLIP animations are efficient when animating elements that change position.
Think about how browsers handle layout and paint during animations.
FLIP stands for First, Last, Invert, Play. It animates elements by calculating position differences and applying transforms, which is GPU-accelerated and avoids costly layout recalculations.