List reorder

Drag the grip, and the rest of the list opens up to show where the row will land. Or tab to a grip, press Space to lift it, move it with the arrows, and press Space again to drop — every step spoken aloud in a live region. The neighbours move with transforms, so the list lays out once per crossing rather than once per frame.

Reorder it

    Tab to a gripSpace lifts↑ ↓ moves Space dropsEsc cancels

    The two things people leave out

    /* 1. the landing index is decided by CENTRES crossing, not by the pointer */
    function indexFor(carriedCentreY){
      let i = 0;
      for (const r of rects) if (carriedCentreY > r.top + r.height / 2) i++;
      return i;
    }
    
    /* 2. the keyboard is the same model, with no pointer in it */
    handle.addEventListener("keydown", e => {
      if (e.key === " " || e.key === "Enter"){ lifted ? drop() : lift(); e.preventDefault(); }
      if (lifted && e.key === "ArrowUp")   { moveBy(-1); e.preventDefault(); }
      if (lifted && e.key === "ArrowDown") { moveBy(+1); e.preventDefault(); }
      if (lifted && e.key === "Escape")    { cancel();  e.preventDefault(); }
    });
    
    /* and every change says what happened, because a reorder is invisible
       to anybody who cannot watch the list settle */
    live.textContent = `${name} is now ${i + 1} of ${n}`;