StealThis .dev

FLIP Layout Animation

A developer-facing grid that animates its items between layouts using the FLIP technique — First, Last, Invert, Play. Shuffle, sort, filter, add, and remove cards while every item glides on a transform-only path, cross-fades on enter and exit, and reflows with GPU-friendly motion. A labeled note breaks down each FLIP stage, and controls plus a reduced-motion toggle let you feel how position deltas become buttery, jank-free transitions from any starting state.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

FLIP Layout Animation shows how to animate a reflowing grid without animating layout properties directly. Instead of tweening top, left, width, or order — which force expensive reflows and cannot be GPU-composited — the component records each item’s First bounding box, mutates the DOM into its Last state, then Inverts the visual delta with a transform and Plays the transform back to zero. The browser only ever composites transform and opacity, keeping the motion on the fast path.

Use the toolbar to shuffle the deck, sort by name or weight, filter by category, or add and remove cards. Every mutation triggers a fresh First/Last measurement pass, so items smoothly slide to their new slots while entering cards scale-and-fade in and leaving cards fade out before removal. A live status line reports how many items moved on the last transition, and an annotated panel maps each on-screen stage back to the four FLIP letters.

The implementation is dependency-free vanilla JS and CSS. It is DPR-agnostic, keyboard-usable, and honors prefers-reduced-motion by snapping straight to the Last state with no inversion. It is a compact, production-minded reference for building sortable dashboards, kanban boards, gallery filters, or any interface where content rearranges and you want the motion to explain the change.