Back to the library

Pane — collapse past the threshold

Variant: Collapse threshold

A split view’s divider dragged past the file pane’s minimum. Inside the minimum the pane follows the finger 1:1; past it the pane gives d·8/(d+8) for d points of overdrag — quick at first, then less and less, never more than 8 — because a fixed ratio reads as a slower pane rather than a stiffer one. The minimum is drawn only while a drag is live, and overdrag tints the pane: the collapse is shown as provisional before it is committed. Released past the line, the pane snaps to a sliver in 256ms, ease-out, from exactly where the band left it, carrying the tint out with it so the commit reads as the warning confirmed. File names fade over the last 8 points before the minimum, so the pane narrows to icons instead of slicing words. A tap on the sliver restores the width the pane had before the drag, not the minimum — the last deliberate choice is the one worth remembering.

gesturephysicslayouttransitionloop

The source

A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Pane — collapse past the threshold</title>
    <style>
      :root {
        /* Neutrals — fixed, never remixed. */
        --ivory: #faf9f5;
        --paper: #ffffff;
        --oat: #e3dacc;
        --slate: #141413;

        /* Knobs — the remix API. A knob exists iff declared here and used below. */
        --hue: 38.8;
        --lift: 0;
        --chroma: 1;
        --round: 1;
        --speed: 1;

        /* Accents — derived from the knobs with the family's offsets baked in,
           so one hue roll moves them together. Defaults reproduce the original hex. */
        --clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
        --clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
        --olive: oklch(
          calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3)
        );
        --rust: oklch(
          calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3)
        );

        /* Clock — 6.4s, so 1% is 64ms. The drag takes 1.47s of hand time; the
           collapse after release takes 256ms and the restore 384ms. */
        --cycle: 6.4s;
        --t: calc(var(--cycle) / var(--speed));

        --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
        --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
        --ease-accent: cubic-bezier(0.32, 0.72, 0, 1);

        /* Positions are percent of the frame's width. The pane's minimum is
           22; the band can stretch at most 8 past it, ever. */
        --_min: 22;
        --_band: 8;
      }

      /* Three registered numbers and everything else is arithmetic on them:
         where the finger is, where the pane would be on its own, and which
         of the two is in charge. */
      @property --_f {
        syntax: '<number>';
        inherits: true;
        initial-value: 46;
      }

      @property --_q {
        syntax: '<number>';
        inherits: true;
        initial-value: 46;
      }

      /* The warning's afterglow: picks the tint up on the release frame and
         carries it out over the collapse, so the commit reads as the warning
         confirmed rather than the warning cleared. */
      @property --_k {
        syntax: '<number>';
        inherits: true;
        initial-value: 0;
      }

      @property --_m {
        syntax: '<number>';
        inherits: true;
        initial-value: 0;
      }

      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }

      body {
        min-height: 100vh;
        display: grid;
        place-items: center;
        background: var(--ivory);
        font-family:
          system-ui,
          -apple-system,
          'Segoe UI',
          Roboto,
          sans-serif;
        color: var(--slate);
      }

      .frame {
        position: relative;
        width: clamp(250px, 64vw, 380px);
        height: clamp(160px, 58vh, 220px);
        container-type: size;
        border-radius: calc(12px * var(--round));
        background: var(--paper);
        border: 1px solid color-mix(in srgb, var(--slate) 10%, transparent);
        overflow: hidden;
        animation: drive var(--t) infinite;

        /* Overdrag d is how far the finger is past the minimum. Inside the
           minimum the pane follows the finger 1:1; past it the pane gives
           d·b/(d+b) — fast at first, then less and less, never more than b.
           That diminishing return is the resistance; a fixed ratio would read
           as a slower pane, not a stiffer one. */
        --_d: max(0, var(--_min) - var(--_f));
        --_drag: calc(
          max(var(--_f), var(--_min)) - var(--_d) * var(--_band) / (var(--_d) + var(--_band))
        );
        --_p: calc(var(--_drag) * (1 - var(--_m)) + var(--_q) * var(--_m));
        /* 0 → 1 over the first 5 points of overdrag, only while held. */
        --_warn: max(calc(min(1, var(--_d) / 5) * (1 - var(--_m))), var(--_k));
        /* Names fade over the last 8 points before the minimum, so the pane
           narrows to its icons instead of slicing words at its edge. */
        --_names: clamp(0, (var(--_p) - var(--_min)) / 8, 1);
      }

      .left {
        position: absolute;
        inset: 0;
        background: color-mix(in srgb, var(--oat) 28%, var(--paper));
        clip-path: inset(0 calc(100% - var(--_p) * 1%) 0 0);
      }

      .left .inner {
        padding: 12px 12px;
        display: flex;
        flex-direction: column;
        gap: 7px;
        opacity: calc(1 - var(--_warn) * 0.5);
      }

      /* The wash says "let go now and this closes" before anything closes.
         Until release nothing is committed, and the preview has to look
         provisional — a tint over the pane, not the pane leaving. */
      .wash {
        position: absolute;
        inset: 0;
        background: color-mix(in srgb, var(--clay) 16%, transparent);
        opacity: var(--_warn);
      }

      .head {
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: color-mix(in srgb, var(--slate) 52%, transparent);
        margin-bottom: 1px;
      }

      .head,
      .file span {
        opacity: var(--_names);
      }

      .file {
        display: flex;
        align-items: center;
        gap: 7px;
        font-size: 12px;
        white-space: nowrap;
        color: color-mix(in srgb, var(--slate) 76%, transparent);
      }

      .file::before {
        content: '';
        width: 8px;
        height: 10px;
        flex: none;
        border-radius: calc(2px * var(--round));
        border: 1.4px solid color-mix(in srgb, var(--slate) 34%, transparent);
      }

      .file.on {
        color: var(--clay-d);
      }

      .file.on::before {
        border-color: var(--clay);
      }

      .right {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: 54cqw;
        padding: 14px 16px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        transform: translateX(calc(var(--_p) * 1cqw));
      }

      .bar {
        display: block;
        height: 7px;
        border-radius: 3.5px;
        background: color-mix(in srgb, var(--slate) 12%, transparent);
      }

      .bar.k {
        background: color-mix(in srgb, var(--olive) 46%, transparent);
      }

      .bar.in {
        margin-left: 12px;
      }

      /* The firebreak: the minimum width, drawn only while a drag is live, so
         the boundary the pane is resisting is visible at the moment it
         matters and absent the rest of the time. */
      .limit {
        position: absolute;
        top: 10px;
        bottom: 10px;
        left: 0;
        width: 0;
        border-left: 1px dashed
          color-mix(
            in srgb,
            var(--clay) calc(var(--_warn) * 100%),
            color-mix(in srgb, var(--slate) 30%, transparent)
          );
        transform: translateX(calc(var(--_min) * 1cqw));
        opacity: 0;
        animation: limit var(--t) infinite;
      }

      .divider {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: 0;
        transform: translateX(calc(var(--_p) * 1cqw));
      }

      .divider::before {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        left: -0.5px;
        width: 1px;
        background: color-mix(in srgb, var(--slate) 11%, transparent);
      }

      .grip {
        position: absolute;
        top: 50%;
        left: -2.5px;
        width: 5px;
        height: 26px;
        margin-top: -13px;
        border-radius: 999px;
        background: color-mix(in srgb, var(--slate) 22%, transparent);
        animation: grip var(--t) infinite;
      }

      .finger {
        position: absolute;
        top: 50%;
        left: -13px;
        width: 26px;
        height: 26px;
        margin-top: -13px;
        border-radius: 50%;
        background: color-mix(in srgb, var(--slate) 12%, transparent);
        translate: calc(var(--_f) * 1cqw) 0;
        opacity: 0;
        animation: finger var(--t) infinite;
      }

      /* The finger travels 46 → 8 on one ease-in-out: a hand leaves rest and
         stops, and it does not know where the minimum is. The pane's motion
         is derived, so the moment of resistance arrives mid-stroke with no
         keyframe marking it. On release, control passes to --_q on the same
         frame it is set to exactly where the band left the pane. */
      @keyframes drive {
        0%,
        9% {
          --_f: 46;
          --_q: 46;
          --_m: 0;
          --_k: 0;
          animation-timing-function: var(--ease-in-out);
        }
        32% {
          --_f: 8;
          --_q: 46;
          --_m: 0;
          --_k: 0;
          animation-timing-function: steps(1, end);
        }
        32.01% {
          --_f: 8;
          --_q: 16.91;
          --_m: 1;
          --_k: 1;
          animation-timing-function: var(--ease-out);
        }
        36% {
          --_f: 8;
          --_q: 1.4;
          --_m: 1;
          --_k: 0;
          animation-timing-function: steps(1, end);
        }
        40%,
        54% {
          --_f: 5.5;
          --_q: 1.4;
          --_m: 1;
          animation-timing-function: var(--ease-accent);
        }
        60% {
          --_f: 5.5;
          --_q: 46;
          --_m: 1;
          animation-timing-function: steps(1, end);
        }
        70%,
        100% {
          --_f: 46;
          --_q: 46;
          --_m: 1;
        }
      }

      @keyframes finger {
        0%,
        6% {
          opacity: 0;
          transform: scale(1.3);
          animation-timing-function: var(--ease-out);
        }
        9%,
        32% {
          opacity: 1;
          transform: scale(1);
          animation-timing-function: var(--ease-out);
        }
        35%,
        49% {
          opacity: 0;
          transform: scale(1.3);
          animation-timing-function: var(--ease-out);
        }
        52%,
        53.5% {
          opacity: 1;
          transform: scale(1);
          animation-timing-function: var(--ease-out);
        }
        57%,
        100% {
          opacity: 0;
          transform: scale(1.3);
        }
      }

      @keyframes grip {
        0%,
        7% {
          background: color-mix(in srgb, var(--slate) 22%, transparent);
          animation-timing-function: ease;
        }
        9%,
        32% {
          background: var(--clay);
          animation-timing-function: ease;
        }
        35%,
        52% {
          background: color-mix(in srgb, var(--slate) 22%, transparent);
          animation-timing-function: ease;
        }
        53.5%,
        56% {
          background: var(--clay);
          animation-timing-function: ease;
        }
        60%,
        100% {
          background: color-mix(in srgb, var(--slate) 22%, transparent);
        }
      }

      @keyframes limit {
        0%,
        9% {
          opacity: 0;
          animation-timing-function: ease;
        }
        13%,
        32% {
          opacity: 1;
          animation-timing-function: ease;
        }
        34.5%,
        100% {
          opacity: 0;
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* No travel: the finger, the stretch and the snap all go. What is left
           is the decision and its outcome — the minimum line and the wash
           fade up as the warning, then the pane is simply closed, then simply
           open again at the width it had. */
        .frame {
          --_p: var(--_q);
          animation: drive-still calc(var(--t) * 1.5) infinite;
        }

        .finger {
          display: none;
        }

        .wash {
          opacity: 0;
          animation: wash-still calc(var(--t) * 1.5) infinite;
        }

        .left .inner {
          opacity: 1;
        }

        .grip {
          animation-duration: calc(var(--t) * 1.5);
        }

        .limit {
          animation-duration: calc(var(--t) * 1.5);
        }

        @keyframes drive-still {
          0%,
          33% {
            --_q: 46;
            animation-timing-function: steps(1, end);
          }
          33.01%,
          55% {
            --_q: 1.4;
            animation-timing-function: steps(1, end);
          }
          55.01%,
          100% {
            --_q: 46;
          }
        }

        @keyframes wash-still {
          0%,
          16% {
            opacity: 0;
            animation-timing-function: ease;
          }
          24%,
          32% {
            opacity: 1;
            animation-timing-function: ease;
          }
          33%,
          100% {
            opacity: 0;
          }
        }
      }
    </style>
  </head>
  <body>
    <div
      class="frame"
      role="img"
      aria-label="A split view whose divider is dragged left: the file pane follows to its minimum width, then resists and tints as a warning; released past the minimum it snaps shut to a sliver, and a tap on the sliver restores it to the width it had before"
    >
      <div class="left">
        <div class="inner">
          <span class="head">Files</span>
          <span class="file on"><span>index.ts</span></span>
          <span class="file"><span>styles.css</span></span>
          <span class="file"><span>README.md</span></span>
          <span class="file"><span>package.json</span></span>
        </div>
        <span class="wash"></span>
      </div>
      <div class="right">
        <span class="bar k" style="width: 34%"></span>
        <span class="bar in" style="width: 70%"></span>
        <span class="bar in" style="width: 58%"></span>
        <span class="bar in" style="width: 76%"></span>
        <span class="bar" style="width: 22%"></span>
        <span class="bar k" style="width: 40%"></span>
        <span class="bar in" style="width: 62%"></span>
      </div>
      <span class="limit"></span>
      <div class="divider">
        <span class="grip"></span>
      </div>
      <span class="finger"></span>
    </div>
  </body>
</html>

The variant family

Same idea, one axis moved. Compare them side by side before you commit.