This content originally appeared on CodeSource.io and was authored by Jatin Hemnani
In this article, you will learn How To Use Svelte Flip Animation.
Importing the Flip Animation
import {flip} from 'svelte/animate'
Here, you have imported the Flip animation from Svelte.
Using The Animation
To use the Flip animation you have to add an animate property to the HTML element inside the {#each} block.
{#each todos as todo (todo.id)}
<div animate:flip={{duration:500}}>
<div>{todo.todo}</div>
<button on:click={()=>deleteTodo(todo.id)}>Delete</button>
</div>
{/each}
Now, after running this code each time a new item is added or removed, it will have a Flip animation.
NOTE: You can use the Flip animation only inside {#each} block.
Result
The post How To Use Svelte Flip Animation appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Jatin Hemnani
Jatin Hemnani | Sciencx (2021-03-02T06:59:22+00:00) How To Use Svelte Flip Animation. Retrieved from https://www.scien.cx/2021/03/02/how-to-use-svelte-flip-animation/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.