Back to the library

Thread — history loads above, your place holds

Variant: History anchor

Scroll anchoring, made visible. The row the reader was on carries a faint bookmark, so the eye has something to hold. They flick up to the top of a channel, a loader takes the top slot, and when the older page lands the loader’s slot becomes a message in place — opacity only, because a row that slid down into the slot would drag the eye and undo the very thing on show — while the bookmarked row and every other row in view stay exactly where they were. Nothing in the list moves, so the scrollbar thumb is the honest witness: it shrinks from five-sevenths of the track to half and drops to three-tenths in 160ms, a readout rather than a gesture, because the reader is now three rows down a longer page without having moved. The rows that land above the fold appear in one frame; fading something nobody can see is work for no one. Then the reader carries on up into the older messages. Their scrolls are ease-out rather than the ease-in-out an on-screen move would get, because a flick is already at speed when it starts. Reach for it for chat history, infinite feeds and log viewers that page backwards; if the content above can change height after it renders, anchor on a row id rather than a pixel offset.

transitionscrolllistloadingloop

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>Thread — history loads above, your place holds</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 — 7.2s, so 1% is 72ms. The reader scrolls into the top at
           6%, the loader runs to 36%, the older page lands in the same frame,
           the reader carries on up from 52%, and the view resets from 84%. */
        --cycle: 7.2s;
        --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);

        --_muted: color-mix(in srgb, var(--slate) 58%, transparent);
        --_track: color-mix(in srgb, var(--oat) 55%, var(--paper));
        --_thumb: color-mix(in srgb, var(--slate) 52%, transparent);
        --_here: color-mix(in srgb, var(--clay) 10%, var(--paper));
        --_a: color-mix(in srgb, var(--clay) 30%, var(--paper));
        --_j: color-mix(in srgb, var(--olive) 32%, var(--paper));
        --_m: color-mix(in srgb, var(--oat) 90%, var(--paper));
        --_row: 28px;
        --_gap: 6px;
        --_pitch: calc(var(--_row) + var(--_gap));
        --_spin: calc(0.8s / var(--speed));
      }

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

      .card {
        width: min(340px, 92vw);
        background: var(--paper);
        border: 1px solid var(--oat);
        border-radius: calc(14px * var(--round));
        overflow: hidden;
      }

      .head {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 32px;
        padding: 0 14px;
        font-size: 12px;
        color: var(--_muted);
        border-bottom: 1px solid var(--oat);
      }

      .head b {
        color: var(--slate);
        font-weight: 600;
      }

      .view {
        position: relative;
        height: calc(5 * var(--_pitch) - var(--_gap) + 16px);
        padding: 8px 20px 8px 10px;
        overflow: hidden;
      }

      /* Three older rows, a slot, then the six already loaded. The strip
         offset is the scroll position, counted in whole rows. */
      .strip {
        display: grid;
        gap: var(--_gap);
        transform: translateY(calc(-4 * var(--_pitch)));
        animation: strip var(--t) infinite;
      }

      .row {
        display: flex;
        align-items: center;
        gap: 8px;
        height: var(--_row);
        padding: 0 6px;
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
      }

      .av {
        flex: none;
        display: grid;
        place-items: center;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        font-size: 11px;
        font-style: normal;
        font-weight: 600;
        background: var(--_m);
      }
      .a .av {
        background: var(--_a);
      }
      .j .av {
        background: var(--_j);
      }

      .row b {
        flex: none;
        font-weight: 600;
      }

      .row span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        color: var(--_muted);
      }

      /* The reader's place, marked so the eye has something to hold: it
         sits at the same height before the page lands and after. */
      .here {
        position: relative;
        isolation: isolate;
      }

      .here::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        border-radius: calc(6px * var(--round));
        background: var(--_here);
      }

      .here::after {
        content: '';
        position: absolute;
        left: 0;
        top: 5px;
        bottom: 5px;
        width: 2px;
        border-radius: 999px;
        background: var(--clay);
      }

      .old {
        opacity: 0;
        animation: old var(--t) infinite;
      }

      .slot {
        position: relative;
        height: var(--_row);
      }

      .slot > * {
        position: absolute;
        inset: 0;
      }

      .loading {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        font-size: 12px;
        color: var(--_muted);
        animation: loading var(--t) infinite;
      }

      .ring {
        width: 13px;
        height: 13px;
        border-radius: 50%;
        border: 1.5px solid var(--oat);
        border-top-color: var(--clay-d);
        animation: spin var(--_spin) linear infinite;
      }

      .slot .old {
        animation-name: landed;
      }

      .track {
        position: absolute;
        top: 8px;
        bottom: 8px;
        right: 5px;
        width: 6px;
        border-radius: 999px;
        background: var(--_track);
      }

      /* The thumb is the only honest witness. The rows in view do not move
         when the page lands — that is the whole job — so the scrollbar is
         where the reader can see that the document just grew above them. */
      .thumb {
        height: 100%;
        border-radius: 999px;
        background: var(--_thumb);
        transform-origin: 50% 0;
        transform: translateY(14.29%) scaleY(0.7143);
        animation: thumb var(--t) infinite;
      }

      /* The reader's own scrolls are ease-out, not the ease-in-out an
         on-screen move would get: this is a flick decaying, already at
         speed when it starts. */
      @keyframes strip {
        0%,
        6% {
          opacity: 1;
          transform: translateY(calc(-4 * var(--_pitch)));
          animation-timing-function: var(--ease-out);
        }
        14%,
        52% {
          opacity: 1;
          transform: translateY(calc(-3 * var(--_pitch)));
          animation-timing-function: var(--ease-out);
        }
        62%,
        84% {
          opacity: 1;
          transform: translateY(calc(-1 * var(--_pitch)));
          animation-timing-function: var(--ease-out);
        }
        88% {
          opacity: 0;
          transform: translateY(calc(-1 * var(--_pitch)));
        }
        88.1% {
          opacity: 0;
          transform: translateY(calc(-4 * var(--_pitch)));
          animation-timing-function: var(--ease-out);
        }
        93%,
        100% {
          opacity: 1;
          transform: translateY(calc(-4 * var(--_pitch)));
        }
      }

      /* Seven rows of content, then ten: the thumb shrinks from 5/7 to 5/10
         of the track and drops to 3/10, because the reader is now three rows
         down a longer page without having moved. 160ms — fast, it is a
         readout, not a gesture. */
      @keyframes thumb {
        0%,
        6% {
          opacity: 1;
          transform: translateY(14.29%) scaleY(0.7143);
          animation-timing-function: var(--ease-out);
        }
        14%,
        36% {
          opacity: 1;
          transform: translateY(0) scaleY(0.7143);
          animation-timing-function: var(--ease-out);
        }
        38.22%,
        52% {
          opacity: 1;
          transform: translateY(30%) scaleY(0.5);
          animation-timing-function: var(--ease-out);
        }
        62%,
        84% {
          opacity: 1;
          transform: translateY(10%) scaleY(0.5);
        }
        88% {
          opacity: 0;
          transform: translateY(10%) scaleY(0.5);
        }
        88.1% {
          opacity: 0;
          transform: translateY(14.29%) scaleY(0.7143);
          animation-timing-function: var(--ease-out);
        }
        93%,
        100% {
          opacity: 1;
          transform: translateY(14.29%) scaleY(0.7143);
        }
      }

      @keyframes loading {
        0%,
        36% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        37.7%,
        100% {
          opacity: 0;
        }
      }

      /* The rows above the fold appear in one frame: nobody can see them
         arrive, and fading something off-screen is work for no one. */
      @keyframes old {
        0%,
        36% {
          opacity: 0;
        }
        36.1%,
        88% {
          opacity: 1;
        }
        88.1%,
        100% {
          opacity: 0;
        }
      }

      /* The one row that lands in view fades in its own place — no slide,
         no push. A row that slid down into the slot would drag the eye with
         it and undo the anchoring it is meant to show. */
      @keyframes landed {
        0%,
        36% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        38.8%,
        88% {
          opacity: 1;
        }
        88.1%,
        100% {
          opacity: 0;
        }
      }

      @keyframes spin {
        to {
          transform: rotate(1turn);
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* The reader's scrolls become dips: the strip fades out at one
           offset and in at the next. The thumb steps instead of sliding,
           and the loader breathes instead of spinning. Everything runs 1.5x. */
        :root {
          --t: calc(var(--cycle) * 1.5 / var(--speed));
        }

        .strip {
          animation-name: strip-still;
        }
        .thumb {
          animation-name: thumb-still;
        }
        .ring {
          border-top-color: var(--oat);
          border-color: var(--clay-d);
          animation: breathe calc(var(--_spin) * 2.5) var(--ease-in-out) infinite alternate;
        }

        @keyframes strip-still {
          0%,
          6% {
            opacity: 1;
            transform: translateY(calc(-4 * var(--_pitch)));
          }
          8% {
            opacity: 0;
            transform: translateY(calc(-4 * var(--_pitch)));
          }
          8.1% {
            opacity: 0;
            transform: translateY(calc(-3 * var(--_pitch)));
          }
          11%,
          52% {
            opacity: 1;
            transform: translateY(calc(-3 * var(--_pitch)));
          }
          54% {
            opacity: 0;
            transform: translateY(calc(-3 * var(--_pitch)));
          }
          54.1% {
            opacity: 0;
            transform: translateY(calc(-1 * var(--_pitch)));
          }
          57%,
          84% {
            opacity: 1;
            transform: translateY(calc(-1 * var(--_pitch)));
          }
          88% {
            opacity: 0;
            transform: translateY(calc(-1 * var(--_pitch)));
          }
          88.1% {
            opacity: 0;
            transform: translateY(calc(-4 * var(--_pitch)));
          }
          93%,
          100% {
            opacity: 1;
            transform: translateY(calc(-4 * var(--_pitch)));
          }
        }

        /* The thumb moves only while the strip is dipped out, so it reads
           the same story in the same order without ever sliding. */
        @keyframes thumb-still {
          0%,
          8% {
            transform: translateY(14.29%) scaleY(0.7143);
          }
          8.1%,
          36% {
            transform: translateY(0) scaleY(0.7143);
          }
          36.1%,
          54% {
            transform: translateY(30%) scaleY(0.5);
          }
          54.1%,
          88% {
            transform: translateY(10%) scaleY(0.5);
          }
          88.1%,
          100% {
            transform: translateY(14.29%) scaleY(0.7143);
          }
        }

        @keyframes breathe {
          from {
            opacity: 0.45;
          }
          to {
            opacity: 1;
          }
        }
      }
    </style>
  </head>
  <body>
    <div
      class="card"
      role="img"
      aria-label="A reader scrolls to the top of a channel and a loader appears; when the older messages arrive, the loader's slot becomes a message and nothing else in view moves, while the scrollbar thumb shrinks and drops to show the page grew above; the reader then scrolls on up into the older messages"
    >
      <div class="head"><b># launch</b><span>4 members</span></div>
      <div class="view">
        <div class="strip" aria-hidden="true">
          <div class="row m old">
            <i class="av">M</i><b>Mei</b><span>Kickoff notes are up</span>
          </div>
          <div class="row j old"><i class="av">J</i><b>Joel</b><span>Who owns the docs?</span></div>
          <div class="row m old"><i class="av">M</i><b>Mei</b><span>I can take those</span></div>
          <div class="slot">
            <div class="loading"><i class="ring"></i>Loading earlier</div>
            <div class="row j old"><i class="av">J</i><b>Joel</b><span>Thanks, Mei</span></div>
          </div>
          <div class="row a here">
            <i class="av">A</i><b>Ana</b><span>Ship the beta Friday?</span>
          </div>
          <div class="row m"><i class="av">M</i><b>Mei</b><span>Docs are nearly done</span></div>
          <div class="row j"><i class="av">J</i><b>Joel</b><span>QA is on it today</span></div>
          <div class="row a"><i class="av">A</i><b>Ana</b><span>Changelog draft is up</span></div>
          <div class="row m"><i class="av">M</i><b>Mei</b><span>Screens are exported</span></div>
          <div class="row j"><i class="av">J</i><b>Joel</b><span>Reviewing it now</span></div>
        </div>
        <div class="track" aria-hidden="true"><div class="thumb"></div></div>
      </div>
    </div>
  </body>
</html>