0
0
Svelteframework~5 mins

Custom transitions in Svelte - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a custom transition in Svelte?
A custom transition in Svelte is a way to create your own animation effect when elements enter or leave the DOM, using JavaScript functions to control how the element changes over time.
Click to reveal answer
intermediate
Which function signature is used to create a custom transition in Svelte?
A custom transition function takes a node and parameters, and returns an object with a 'css' function that defines the animation styles over time, and optionally a 'tick' function for JavaScript updates.
Click to reveal answer
beginner
How do you apply a custom transition to an element in Svelte?
You import the custom transition function and use the 'transition:' directive on the element, passing the function and any parameters, like <div transition:myTransition={{ duration: 500 }}></div>.
Click to reveal answer
intermediate
What does the 'css' function inside a custom transition return?
The 'css' function returns a string of CSS styles that change over time, using the progress parameter (from 0 to 1) to animate properties like opacity or transform.
Click to reveal answer
intermediate
Why might you use a custom transition instead of built-in ones in Svelte?
Custom transitions let you create unique animations tailored to your design, beyond the simple fade or slide, giving you full control over timing, easing, and style changes.
Click to reveal answer
What parameter does the 'css' function in a custom transition receive?
AThe DOM node itself
BA progress value from 0 to 1
CThe event object
DThe transition duration in milliseconds
How do you trigger a custom transition on an element in Svelte?
ABy calling a JavaScript animation library
BUsing the 'animate:' directive
CUsing the 'transition:' directive with the custom function
DBy adding a CSS class manually
Which of these is NOT part of a custom transition function's return object?
A'render' function
B'tick' function
C'duration' number
D'css' function
What does the 'tick' function in a custom transition do?
ARuns JavaScript code on each animation frame
BDefines CSS styles for the transition
CSets the transition duration
DHandles user input events
Which Svelte directive is used to import and apply a custom transition?
Ause:
Banimate:
Cbind:
Dtransition:
Explain how to create and use a custom transition in Svelte.
Think about the function signature and how Svelte applies transitions.
You got /4 concepts.
    Describe the difference between the 'css' and 'tick' functions in a custom transition.
    One is for CSS, the other for JavaScript during animation.
    You got /4 concepts.