Back to the library

Transit — arc, not line

Variant: Arc

A token crossing a long diagonal along a curve instead of the straight chord. Nothing in the file is a path: the move is two nested carriers, one per axis, each on its own curve. Horizontal runs a strong ease-in-out; vertical runs a softer curve that leads it, so when x is 9% of the way across, y is over a third of the way up, and the token bows out by about a seventh of the chord. Both curves start and end flat, so the token leaves and lands at rest. Over a long diagonal a straight line reads as mechanical; an arc reads as carried. Both carriers play half the cycle on alternate, so the trip back is the trip out reversed, curves included: the lead becomes a lag and the token retraces its arc instead of drawing the mirror one. Reach for it when an element travels a long way in two dimensions, like a card filed to a sidebar or a chip moving between columns. Under reduced motion the token crossfades between the sockets.

transitionspatialeasinglayoutloop

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>Transit — arc, not line</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;
        --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 — 3.2s, played as two 1.6s halves on alternate: rest 600ms,
           400ms out, rest 600ms, then the same half backwards. That gives
           1.2s at each socket, matching the rest of the family. */
        --cycle: 3.2s;
        --t: calc(var(--cycle) / var(--speed));

        /* The horizontal axis. Symmetric, so it runs the same either way. */
        --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
        /* The vertical axis leads: it is over a third of the way up while x
           has barely left. It still starts and ends flat, so the token leaves
           and lands at rest on both axes, which matters on the reversed half.
           Two curves on two axes is what bends the path. */
        --ease-accent: cubic-bezier(0.4, 0.08, 0.25, 1);

        --_d: 28px;
      }

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

      .stage {
        display: grid;
        gap: clamp(10px, 3vh, 16px);
        justify-items: center;
      }

      .track {
        position: relative;
        overflow: clip;
        /* The carriers are track-sized, so in flight their empty boxes run
           past the edge; clipping here keeps the page from scrolling. The
           margin leaves room for the token's shadow. */
        overflow-clip-margin: 4px;
        width: min(280px, 78vw);
        height: clamp(96px, 34vh, 140px);
      }

      .socket {
        position: absolute;
        width: var(--_d);
        height: var(--_d);
        border-radius: 50%;
        border: 1.5px dashed color-mix(in srgb, var(--slate) 22%, transparent);
      }

      .socket.a {
        left: 0;
        bottom: 0;
      }

      .socket.b {
        right: 0;
        top: 0;
      }

      /* Two carriers the size of the track, one per axis, so each percentage
         resolves against the distance it has to cover and the token's own
         width comes off once. Nested, their translates add — and because each
         runs its own curve, the sum is a curve. */
      .x,
      .y {
        position: absolute;
        inset: 0;
      }

      /* Both carriers run half the cycle on alternate, so the return is the
         outbound move played backwards — curves included. Reversed, y's lead
         becomes a lag, and the token retraces the arc it came out on instead
         of drawing its mirror image. */
      .x {
        animation: arc-x calc(var(--t) / 2) var(--ease-in-out) infinite alternate;
      }

      .y {
        animation: arc-y calc(var(--t) / 2) var(--ease-accent) infinite alternate;
      }

      .token {
        position: absolute;
        left: 0;
        bottom: 0;
        width: var(--_d);
        height: var(--_d);
        border-radius: 50%;
        background: var(--clay);
        box-shadow: 0 1px 2px color-mix(in srgb, var(--clay-d) 40%, transparent);
      }

      .token.ghost {
        display: none;
      }

      .cap {
        font-size: 11.5px;
        letter-spacing: 0.02em;
        color: color-mix(in srgb, var(--slate) 55%, transparent);
      }

      @keyframes arc-x {
        0%,
        37.5% {
          transform: translateX(0);
        }
        62.5%,
        100% {
          transform: translateX(calc(100% - var(--_d)));
        }
      }

      @keyframes arc-y {
        0%,
        37.5% {
          transform: translateY(0);
        }
        62.5%,
        100% {
          transform: translateY(calc(var(--_d) - 100%));
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* No travel, so no path. The token leaves one socket and appears in
           the other, the two fades overlapping so there is never an instant
           with nothing on screen. */
        .x,
        .y {
          animation: none;
        }

        .token {
          animation: seat-a calc(var(--t) * 0.8) ease infinite alternate;
        }

        .token.ghost {
          left: auto;
          bottom: auto;
          right: 0;
          top: 0;
          display: block;
          animation-name: seat-b;
        }

        @keyframes seat-a {
          0%,
          37.5% {
            opacity: 1;
          }
          62.5%,
          100% {
            opacity: 0;
          }
        }

        @keyframes seat-b {
          0%,
          37.5% {
            opacity: 0;
          }
          62.5%,
          100% {
            opacity: 1;
          }
        }
      }
    </style>
  </head>
  <body>
    <div
      class="stage"
      role="img"
      aria-label="A dot travels from a lower-left socket to an upper-right socket along a curved path, rests, and returns along the same curve"
    >
      <div class="track">
        <span class="socket a"></span>
        <span class="socket b"></span>
        <div class="x">
          <div class="y"><span class="token"></span></div>
        </div>
        <span class="token ghost"></span>
      </div>
      <p class="cap">x eases in-out · y leads it</p>
    </div>
  </body>
</html>

The variant family

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