StealThis .dev

Layout Animation

Elements smoothly animate their layout position when reordered or resized using the FLIP (First, Last, Invert, Play) technique. Shuffle and filter grid items with fluid transitions.

Labで開く
css javascript vue svelte
ターゲット: TS JS HTML React Vue Svelte

コード

Layout Animation

Smoothly animate elements between layout positions using the FLIP technique (First, Last, Invert, Play). When items are shuffled, filtered, or resized, they glide to their new positions instead of jumping.

How it works

  1. First — capture every element’s bounding rect before the DOM change
  2. Last — perform the DOM change (reorder, filter, resize), then capture the new rects
  3. Invert — apply a transform that moves each element from its new position back to the old one
  4. Play — remove the transform with a CSS transition so elements animate to their final position

Use cases

  • Photo / product grid filtering
  • Shuffling card decks
  • Kanban column reordering
  • Dashboard widget rearrangement