MotionLightweight
FLIP transitions
Smooth movement when the layout changes.
Smooth movement when the layout changes: cards that glide from a list into a grid, an image that grows from a thumbnail into a full page. The trick is measuring before and after, then animating the difference.
- Breaks when
- breaks with transforms already on the element
- Also called
- FLIP, View Transitions API, layoutId, shared element
Prompts
List to grid without a library
A gallery that toggles between a list and a 4-column grid with FLIP in vanilla JS: before toggling, record getBoundingClientRect for every card; after applying the new class, compute the delta and scale, set transform to invert, force a reflow, then animate to none over 480 ms with cubic-bezier(.2,.8,.2,1) using the Web Animations API. Stagger 20 ms by index. Children with their own transforms use a counter-scale so text does not stretch.
Shared element between pages
Use the View Transitions API for a thumbnail → detail page: assign view-transition-name to the clicked image and the hero image, customise ::view-transition-old/new for a 400 ms crossfade plus the automatic FLIP move, and provide the JS fallback (manual FLIP with a cloned image) for browsers without it.
Reorder animation for a sortable list
When a list re-sorts (data change), animate every item to its new position with FLIP, including items entering (fade + scale from 0.9) and leaving (fade out at their old position via a clone). Batch the measurements in one read phase and one write phase to avoid layout thrash.
Related
Resources · 1
- FLIP Your Animationsaerotwistsite · codeJun 8, 2026