Complete the code to import the animate directive from Svelte.
import { [1] } from 'svelte/animate';
The animate directive is imported from svelte/animate to enable animations between state changes.
Complete the code to apply the animate directive to a list with the flip animation.
<ul animate:[1]=[2]> {#each items as item} <li>{item}</li> {/each} </ul>
fade or slide with animate directive.The flip animation is the built-in animation used with the animate directive to smoothly rearrange list items.
Fix the error in the animate directive usage by completing the code correctly.
<ul animate:[1]={flip}> {#each items as item} <li>{item}</li> {/each} </ul>
animate:animate.The animate directive expects the animation function without calling it. So use flip, not flip().
Fill both blanks to create a reactive list that animates item reordering with the flip animation.
<script> import { [1] } from 'svelte/animate'; let items = [1, 2, 3]; function shuffle() { items = items.sort(() => Math.random() - 0.5); } </script> <button on:click={shuffle}>Shuffle</button> <ul animate:[2]={flip}> {#each items as item} <li>{item}</li> {/each} </ul>
Import and use the flip animation for the animate directive to smoothly animate the shuffled list.
Fill all three blanks to animate a list with flip and add a custom duration option.
<script> import { [1] } from 'svelte/animate'; let items = ["a", "b", "c"]; let options = { duration: [2] }; </script> <ul animate:[3]={flip}> {#each items as item} <li>{item}</li> {/each} </ul>
Import flip, set duration to 300ms, and use flip in the animate directive for smooth animation with custom timing.