StealThis .dev
Patterns Medium

Reorder List

Draggable list where items can be reordered by dragging. Items animate to new positions smoothly using the FLIP technique for fluid layout transitions.

Open in Lab
css javascript vue svelte
Targets: TS JS HTML React Vue Svelte

Code

Reorder List

A draggable sortable list with smooth FLIP animations. Grab any item and drag it to a new position — all other items glide out of the way.

How it works

  1. pointerdown on an item captures the dragged element and creates a floating clone
  2. pointermove positions the clone under the cursor and determines the insertion point
  3. Before reordering the DOM, every item’s rect is captured (First)
  4. The DOM is reordered, new rects are captured (Last), then Invert + Play animates items to their new slots
  5. pointerup drops the item and removes the clone

Key features

  • Pointer Events API for unified mouse + touch support
  • FLIP animation ensures items never teleport
  • Visual placeholder shows where the item will land
  • Grab cursor and elevation change on drag

Use cases

  • Task / priority lists
  • Playlist ordering
  • Layer ordering in design tools