DEV Community

UI Motion AI
UI Motion AI

Posted on

Building a list to grid without a framework

Switching layouts without teleporting.

A view switcher that rearranges the same items into a grid and animates each from where it was.

demo

The trick

This is FLIP by hand: I record every item's rect, switch the layout class, then animate from the old offset to none.

Reduced motion skips the animation and leaves the layout change.

function setMode(m,anim){const a=new Map(items.map(e=>[e,e.getBoundingClientRect()]));
SG.onclick=e=>{const b=e.target.closest('button');if(b)setMode(b.dataset.m,true)};
Enter fullscreen mode Exit fullscreen mode

Where I'd use it

Gallery and file views

Items fade to .4 opacity as they travel, which hides the odd moment when sizes change mid-flight.

The prompt for this one is free: uimotion.app.

Top comments (0)