美文网首页
Getting started with Svelte - An

Getting started with Svelte - An

作者: 游文影月志 | 来源:发表于2023-12-05 16:15 被阅读0次

The flip function calculates the start and end position of an element and animates between them, translating the x and y values. flip stands for First, Last, Invert, Play.

<script>
    import { flip } from 'svelte/animate';
    import { quintOut } from 'svelte/easing';

    let list = [1, 2, 3];
</script>

{#each list as n (n)}
    <div animate:flip={{ delay: 250, duration: 250, easing: quintOut }}>
        {n}
    </div>
{/each}

Note that all the transitions and animations are being applied with CSS, rather than JavaScript, meaning they won't block (or be blocked by) the main thread.

相关文章

网友评论

      本文标题:Getting started with Svelte - An

      本文链接:https://www.haomeiwen.com/subject/kwzlgdtx.html