Performance: Flip animations
MEDIUM IMPACT
Flip animations impact the smoothness of visual transitions and the responsiveness of user interactions during element position changes.
import { flip } from 'svelte/animate'; <ul> {#each items as item (item.id)} <li animate:flip>{item.name}</li> {/each} </ul>
let items = [...]; // On reorder, directly change element styles like top/left // or manipulate DOM causing layout recalculations function reorder() { items = reorderedItems; // no animation or use top/left changes triggering layout }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct top/left animation | High (style changes trigger layout) | Multiple per frame | High (layout + paint) | [X] Bad |
| Svelte flip animation (transform) | Low (no layout changes) | Zero during animation | Low (composite only) | [OK] Good |