Back to the library

End feel — springy block

Variant: Springy block

The range carries on, but something is standing in it — dates already booked, seats taken, a span another lock holds. The thumb hits the hatched block at speed and rebounds three times, and the rebounds are gravity, not a spring: the hand keeps pushing, so each hop is an exact parabola and each one is a third the height of the last and √⅓ as long. That fixed ratio is why it reads as one material rather than three animations. The edge knocks clay on the first two contacts, the readout holds 70 throughout because the bounce is the feel and not a change of value, and there is no rust anywhere: a rebound says “occupied”, which is information, not an error. Reach for it when the limit is somebody else’s claim on the range rather than the end of it.

physicscontrolgestureloop

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>End feel — springy block</title>
    <style>
      /* Three registered numbers: where the thumb is (--_p), where the hand
         is (--_h), and what the readout says (--_v). Thumb and hand share
         keyframes until contact, so they are pixel-identical while gripped
         and the frame they part is the frame the block is felt. */
      @property --_p {
        syntax: '<number>';
        inherits: true;
        initial-value: 20;
      }
      @property --_h {
        syntax: '<number>';
        inherits: true;
        initial-value: 20;
      }
      @property --_v {
        syntax: '<integer>';
        inherits: true;
        initial-value: 20;
      }

      :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)
        );

        --_muted: color-mix(in srgb, var(--slate) 52%, transparent);
        --_rail: color-mix(in srgb, var(--oat) 60%, transparent);
        --_zone: color-mix(in srgb, var(--slate) 18%, transparent);
        --_edge: color-mix(in srgb, var(--slate) 40%, transparent);

        /* Clock — 4.4s: drag, contact, three rebounds, a held push, release. */
        --cycle: 4.4s;
        --t: calc(var(--cycle) / var(--speed));

        --_w: min(232px, 70vw);
      }

      * {
        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);
      }

      .rig {
        display: grid;
        gap: 14px;
        justify-items: center;
        animation: rig-cycle var(--t) linear infinite;
      }

      .cap,
      .foot {
        font-size: 11px;
        letter-spacing: 0.04em;
        color: var(--_muted);
      }

      .foot {
        opacity: 0;
        animation: foot-in var(--t) linear infinite;
      }

      .box {
        position: relative;
        width: var(--_w);
        height: 78px;
        animation:
          thumb var(--t) infinite,
          hand var(--t) infinite;
      }

      .rail {
        position: absolute;
        left: 0;
        right: 0;
        top: 45px;
        height: 4px;
        border-radius: 2px;
        background: var(--_rail);
        overflow: hidden;
      }

      .fill {
        position: absolute;
        inset: 0;
        background: var(--clay);
        transform-origin: left center;
        transform: scaleX(calc(var(--_p) / 100));
      }

      /* Something occupies 70–100. It starts one thumb-radius past 70, so
         the thumb's edge meets it on the frame the value reaches 70. The
         hatch says "taken", not "forbidden" — no rust anywhere in this file. */
      .block {
        position: absolute;
        left: calc(var(--_w) * 0.7 + 10px);
        width: calc(var(--_w) * 0.3);
        top: 38px;
        height: 18px;
        border-radius: calc(4px * var(--round));
        background: repeating-linear-gradient(
          -45deg,
          var(--_zone) 0 1.5px,
          var(--ivory) 1.5px 4.5px
        );
      }

      .edge {
        position: absolute;
        left: calc(var(--_w) * 0.7 + 10px);
        top: 37px;
        width: 3px;
        height: 20px;
        border-radius: 1.5px;
        background: var(--_edge);
        animation: knock var(--t) infinite;
      }

      .carrier {
        position: absolute;
        left: 0;
        top: 34px;
        width: 0;
        height: 26px;
        transform: translateX(calc(var(--_w) * var(--_p) / 100));
      }

      .thumb {
        position: absolute;
        left: -10px;
        top: 3px;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background: var(--paper);
        border: 1.5px solid var(--oat);
        box-shadow: 0 2px 6px color-mix(in srgb, var(--slate) 16%, transparent);
      }

      .chip {
        position: absolute;
        left: 0;
        top: -32px;
        transform: translateX(-50%);
        padding: 2px 7px;
        border-radius: calc(7px * var(--round));
        background: var(--paper);
        border: 1px solid var(--oat);
        font-size: 12px;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
      }

      .chip::before {
        counter-reset: v var(--_v);
        content: counter(v);
      }

      .ghost {
        position: absolute;
        left: 0;
        top: 0;
        transform: translate(calc(var(--_w) * var(--_h) / 100), 47px);
      }

      .lift {
        position: relative;
        display: block;
        width: 14px;
        height: 18px;
        opacity: 0;
        animation: lift var(--t) infinite;
      }

      .arrow {
        display: block;
        width: 100%;
        height: 100%;
        fill: var(--slate);
        stroke: var(--ivory);
        stroke-width: 1.4;
        stroke-linejoin: round;
      }

      .tip {
        position: absolute;
        left: -9px;
        top: -9px;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background: var(--clay-d);
        opacity: 0;
        transform: scale(0.5);
        animation: grip var(--t) infinite;
      }

      /* A bounce under constant pressure, not a spring. The hand keeps
         pushing, so it acts like gravity: every hop is an exact parabola
         (the two Béziers are the true quadratic halves, so each landing is
         as fast as its takeoff), each rebound a third the height of the
         last (6.5, 2.2, 0.7 units) and √⅓ the duration (110, 64, 37ms each
         way). That fixes restitution at √⅓ from the second contact on,
         which is what makes it read as one material. The readout holds 70
         throughout: the rebound is the feel, not a change of value. */
      @keyframes thumb {
        0%,
        8% {
          --_p: 20;
          --_v: 20;
          animation-timing-function: cubic-bezier(0.4, 0, 0.85, 0.75);
        }
        18% {
          --_p: 70;
          --_v: 70;
          animation-timing-function: cubic-bezier(0.333, 0.667, 0.667, 1);
        }
        20.5% {
          --_p: 63.5;
          --_v: 70;
          animation-timing-function: cubic-bezier(0.333, 0, 0.667, 0.333);
        }
        23% {
          --_p: 70;
          --_v: 70;
          animation-timing-function: cubic-bezier(0.333, 0.667, 0.667, 1);
        }
        24.45% {
          --_p: 67.8;
          --_v: 70;
          animation-timing-function: cubic-bezier(0.333, 0, 0.667, 0.333);
        }
        25.9% {
          --_p: 70;
          --_v: 70;
          animation-timing-function: cubic-bezier(0.333, 0.667, 0.667, 1);
        }
        26.75% {
          --_p: 69.3;
          --_v: 70;
          animation-timing-function: cubic-bezier(0.333, 0, 0.667, 0.333);
        }
        27.6%,
        97% {
          --_p: 70;
          --_v: 70;
        }
        98%,
        100% {
          --_p: 20;
          --_v: 20;
        }
      }

      @keyframes hand {
        0%,
        8% {
          --_h: 20;
          animation-timing-function: cubic-bezier(0.4, 0, 0.85, 0.75);
        }
        18% {
          --_h: 70;
          animation-timing-function: cubic-bezier(0.1, 0.52, 0.3, 1);
        }
        25%,
        32% {
          --_h: 82;
          animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
        }
        35% {
          --_h: 76;
          animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
        }
        38%,
        97% {
          --_h: 82;
        }
        98%,
        100% {
          --_h: 20;
        }
      }

      @keyframes lift {
        0%,
        3% {
          opacity: 0;
          transform: translate(18px, 40px);
          animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
        }
        8%,
        46% {
          opacity: 1;
          transform: translate(0, 0);
          animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
        }
        53%,
        100% {
          opacity: 0;
          transform: translate(2px, 26px);
        }
      }

      /* The grip disc is thumb-sized only while it holds the thumb. The
         frame they part it shrinks to a fingertip, so the pointer out past
         the limit never reads as a second thumb. */
      @keyframes grip {
        0%,
        7% {
          opacity: 0;
          transform: scale(0.5);
          animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
        }
        8%,
        18% {
          opacity: 0.4;
          transform: scale(1);
          animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
        }
        19.5%,
        45.5% {
          opacity: 0.4;
          transform: scale(0.45);
          animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
        }
        47.5%,
        100% {
          opacity: 0;
          transform: scale(0.5);
        }
      }

      /* The edge knocks on the first two contacts, the second fainter;
         the third is too small to report. */
      @keyframes knock {
        0%,
        17.9% {
          background: var(--_edge);
        }
        18% {
          background: var(--clay-d);
          animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
        }
        21%,
        22.9% {
          background: var(--_edge);
        }
        23% {
          background: color-mix(in srgb, var(--clay-d) 60%, var(--_edge));
          animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
        }
        25.5%,
        100% {
          background: var(--_edge);
        }
      }

      @keyframes foot-in {
        0%,
        48% {
          opacity: 0;
          animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
        }
        52%,
        88% {
          opacity: 1;
        }
        92%,
        100% {
          opacity: 0;
        }
      }

      @keyframes rig-cycle {
        0% {
          opacity: 0;
        }
        3%,
        90% {
          opacity: 1;
        }
        95%,
        100% {
          opacity: 0;
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* The rebounds go; the obstacle stays. The thumb is parked against
           the hatch and the edge breathes clay, so the card still says
           "something is in the way". */
        .rig,
        .box,
        .lift {
          animation: none;
        }

        .box {
          --_p: 70;
          --_v: 70;
        }

        .foot {
          animation: none;
          opacity: 1;
        }

        .edge {
          animation: knock-rest calc(var(--t) * 1.6) ease infinite;
        }

        @keyframes knock-rest {
          0%,
          10% {
            background: var(--_edge);
          }
          40%,
          60% {
            background: var(--clay-d);
          }
          90%,
          100% {
            background: var(--_edge);
          }
        }
      }
    </style>
  </head>
  <body>
    <div
      class="rig"
      role="img"
      aria-label="A slider dragged into an occupied stretch of its range: the thumb hits the hatched block at 70 and rebounds three times, each smaller and quicker, before settling against it"
    >
      <p class="cap">end feel · springy block</p>
      <div class="box">
        <div class="rail"><i class="fill"></i></div>
        <i class="block"></i>
        <i class="edge"></i>
        <div class="carrier">
          <span class="chip"></span>
          <span class="thumb"></span>
        </div>
        <span class="ghost">
          <span class="lift">
            <span class="tip"></span>
            <svg class="arrow" viewBox="0 0 14 18">
              <path d="M1 1 L1 14.8 L4.5 11.6 L6.7 16.6 L9.3 15.4 L7.1 10.5 L11.8 10.3 Z" />
            </svg>
          </span>
        </span>
      </div>
      <p class="foot">rebounded off 70 — the rest is taken</p>
    </div>
  </body>
</html>

The variant family

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