Anchored Auto Layout
npm

Hover or focus a box to measure it. Click its tag, or press ] and [, to pin one. Esc unpins.

    Legend
    • Anchor: a box with data-⚓️-name
    • Placed by anchors: out of flow
    • Gap from the anchor's edge, in px
    • Edges of the box you're inspecting

    Every tag, line and number here is itself placed by data-⚓️-* attributes. JS only measures.

    Magnetic table columns: values glide to new anchors

    Recreates the 'tables that split, stretch and snap into place' interaction (Operate, Alvish Baldha).

    Full page
    <main class="demo">
      <header class="intro">
        <h1>Magnetic columns</h1>
        <p>
          Drag the grip (or use the arrow keys) and let go: the table snaps to a stop, and every value pulls
          toward its new column. The grid underneath is a set of invisible slots that reflow <em>instantly</em> at each
          width, changing which column a value lives in and how it's aligned. Each visible value is
          <code>data-⚓️-fill</code> on its slot with <code>data-⚓️-transition="glide"</code>, so it travels
          there instead of teleporting (the same trick as the masonry demo), with a springy ease and a small per-column stagger for the magnet feel.
          The panel itself is <code>data-⚓️-to</code> the stage and the grip rides it with <code>data-⚓️-side="after"</code>.
          The script only writes one number, the panel width.
        </p>
      </header>
    
      <div class="controls">
        <output class="readout" id="readout" aria-live="polite"></output>
        <label class="xray-toggle"><input type="checkbox" id="xray"> X-ray (show the slots)</label>
      </div>
    
      <div class="window">
        <div class="viewport" data-⚓️-root>
          <div class="stage" data-⚓️-name="--stage" aria-hidden="true"></div>
    
          <div class="stops" aria-hidden="true"></div>
    
          <section class="panel" aria-label="Deals"
            data-⚓️-name="--panel"
            data-⚓️-to="--stage"
            data-⚓️-align-leading
            data-⚓️-stretch-y>
            <header class="panel-head"><b>Deals</b><span class="count">11</span></header>
            <div class="panel-body">
              <div class="row labels" aria-hidden="true"></div>
              <div class="rows"></div>
            </div>
          </section>
    
          <div class="grip" role="separator" aria-orientation="vertical" aria-label="Resize deals table" tabindex="0"
            data-⚓️-to="--panel"
            data-⚓️-side="after"
            data-⚓️-stretch-y></div>
        </div>
      </div>
    </main>

    data-⚓️-align-leadingdata-⚓️-filldata-⚓️-namedata-⚓️-rootdata-⚓️-scope-namedata-⚓️-sidedata-⚓️-stretch-ydata-⚓️-todata-⚓️-transition

    Copied