Recall & Review
beginner
What is the purpose of the
crossfade function in Svelte?The
crossfade function creates smooth transitions between elements entering and leaving the DOM, making list items fade and move gracefully instead of appearing or disappearing abruptly.Click to reveal answer
beginner
How do you import the <code>crossfade</code> function in a Svelte component?You import it from <code>svelte/animate</code> like this: <br><code>import { crossfade } from 'svelte/animate';</code>Click to reveal answer
intermediate
What are the two functions returned by
crossfade() and what are they used for?The
crossfade() function returns two functions: send and receive. <br>- send is used on elements leaving the DOM to animate their exit.<br>- receive is used on elements entering the DOM to animate their entrance.Click to reveal answer
beginner
Why do list items need a unique
key when using crossfade in Svelte?A unique
key helps Svelte track which items are entering or leaving so it can match them and apply the crossfade animation correctly between the old and new elements.Click to reveal answer
intermediate
How can you customize the duration of the crossfade animation in Svelte?
You can pass options to <code>crossfade()</code>, such as <code>duration</code>, to control how long the animation lasts. For example:<br><code>const [send, receive] = crossfade({ duration: d => Math.sqrt(d * 200) });</code>Click to reveal answer
What does the
crossfade function in Svelte help you do?✗ Incorrect
Crossfade creates smooth animations for elements entering or leaving, making transitions look natural.
Which two functions does
crossfade() return?✗ Incorrect
The crossfade function returns send (for leaving elements) and receive (for entering elements) functions.
Why is it important to use a unique
key on list items when using crossfade?✗ Incorrect
Unique keys let Svelte track which items correspond between old and new lists for smooth animation.
Where do you import the
crossfade function from in Svelte?✗ Incorrect
crossfade is part of the animate module in Svelte.
How can you change the speed of the crossfade animation?
✗ Incorrect
You customize animation timing by setting the duration option in crossfade.
Explain how the crossfade function works in Svelte to animate list items when they change.
Think about how elements leave and enter the list and how Svelte matches them.
You got /5 concepts.
Describe the steps to add a crossfade animation to a list of items in a Svelte component.
Focus on imports, function usage, and keys.
You got /5 concepts.