0
0
Svelteframework~10 mins

Transition directive (transition:fade) in Svelte - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to apply a fade transition to the paragraph when it appears.

Svelte
<script>
  import { fade } from 'svelte/transition';
  let visible = true;
</script>

<button on:click={() => visible = !visible}>Toggle</button>

{#if visible}
  <p [1]={fade}>Hello, I fade in and out!</p>
{/if}
Drag options to blanks, or click blank then click option'
Atransition:fade
Btransition
Canimate:fade
Duse:fade
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'animate:fade' instead of 'transition:fade'.
Using 'use:fade' which is for actions, not transitions.
Omitting 'fade' after the colon.
2fill in blank
medium

Complete the code to import the fade transition correctly.

Svelte
<script>
  import [1] from 'svelte/transition';
  let show = true;
</script>
Drag options to blanks, or click blank then click option'
Afade
BfadeTransition
CfadeEffect
DfadeIn
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect import names like 'fadeTransition' or 'fadeEffect'.
Forgetting to import fade at all.
3fill in blank
hard

Fix the error in the transition directive to make the fade work.

Svelte
<p transition=[1]>Fade me!</p>
Drag options to blanks, or click blank then click option'
Afade()
B(fade)
C{fade}
Dfade
Attempts:
3 left
💡 Hint
Common Mistakes
Adding parentheses like 'fade()' which causes errors.
Using curly braces inside the directive.
4fill in blank
hard

Fill both blanks to create a fade transition with a duration of 500 milliseconds.

Svelte
<script>
  import { fade } from 'svelte/transition';
  let visible = true;
</script>

{#if visible}
  <div [1]={{fade}} [2]={{ duration: 500 }}>Fade with duration</div>
{/if}
Drag options to blanks, or click blank then click option'
Atransition:fade
Btransition
Cuse
Danimate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'use' or 'animate' instead of 'transition'.
Putting the duration object in the wrong place.
5fill in blank
hard

Fill all three blanks to create a fade transition that starts with opacity 0 and lasts 1000 milliseconds.

Svelte
<script>
  import { fade } from 'svelte/transition';
  let show = true;
</script>

{#if show}
  <section [1]={{fade}} [2]={{ duration: [3] }}>Welcome!</section>
{/if}
Drag options to blanks, or click blank then click option'
Atransition:fade
Bduration
C1000
Ddelay
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delay' instead of 'duration'.
Putting the duration value as a string instead of a number.