0
0
Svelteframework~5 mins

Transition directive (transition:fade) in Svelte - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the transition:fade directive do in Svelte?
It smoothly changes the opacity of an element when it enters or leaves the DOM, creating a fading effect.
Click to reveal answer
beginner
How do you apply a fade transition to an element in Svelte?
Add transition:fade inside the element's tag, like <div transition:fade>...</div>.
Click to reveal answer
intermediate
Can you customize the duration of the fade transition in Svelte? How?
Yes, by passing an object with options like { duration: 500 } to fade, e.g., transition:fade={{ duration: 500 }}.
Click to reveal answer
beginner
What happens if you remove an element with transition:fade applied?
The element fades out smoothly before it is removed from the DOM.
Click to reveal answer
beginner
Why is using transition:fade better than instantly hiding elements?
Because it creates a smooth visual effect that is easier on the eyes and improves user experience by showing changes clearly.
Click to reveal answer
What does transition:fade control in Svelte?
AOpacity of an element during enter and leave
BPosition of an element on the screen
CBackground color change
DFont size animation
How do you specify a 1-second fade duration in Svelte?
A<code>transition:fade(1000)</code>
B<code>transition:fade={{ duration: 1000 }}</code>
C<code>fade-duration=1000</code>
D<code>transition:fade-duration=1000</code>
When does the fade-out effect happen?
AWhen the element is added to the DOM
BWhen the page loads
CWhen the element is clicked
DWhen the element is removed from the DOM
Which import is needed to use fade in Svelte?
A<code>import { fade } from 'svelte/effects';</code>
B<code>import fade from 'svelte/fade';</code>
C<code>import { fade } from 'svelte/transition';</code>
DNo import needed
What is the default duration of fade transition if not specified?
A400 milliseconds
B1000 milliseconds
C200 milliseconds
DNo duration, instant
Explain how to add a fade transition to an element in Svelte and customize its duration.
Think about the directive syntax and import statement.
You got /3 concepts.
    Describe what happens visually when an element with transition:fade is removed from the page.
    Focus on the fade-out behavior.
    You got /3 concepts.