kitbash Sign in Connect agent
Components

Drifting print field

The signature: staggered columns of prints drift upward at different speeds over a centred name; hover a print and the rest fade back.

Part of the style

Drifting Print Field

6 parts that belong together, with their tokens, type and rules.

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #f5f5f5;
  --paper: #5c5c87;
  --ink-soft: #e4dbc3;
  --shade: #64648d;
}
</style>

<section class="field" aria-label="Selected pictures">
  <span class="field__plus" aria-hidden="true"></span>
  <h2 class="field__name">Ilse Marwood</h2>
  <div class="field__cols">
    <div class="field__col field__col--outer" data-speed="14" data-offset="120">
      <div class="field__track">
        <a class="field__print field__print--tall" href="#"><img class="field__img" src="assets/dunes-tall.jpg" alt="A dirt road toward pale hills" width="534" height="800"></a>
        <a class="field__print field__print--wide field__print--mono" href="#"><img class="field__img" src="assets/wave-fjord.jpg" alt="Waves breaking on dark stones" width="800" height="450"></a>
        <a class="field__print field__print--tall" href="#"><img class="field__img" src="assets/sitter.jpg" alt="An old portrait of a woman with long hair" width="634" height="800"></a>
      </div>
    </div>
    <div class="field__col" data-speed="22" data-offset="40">
      <div class="field__track">
        <a class="field__print field__print--wide" href="#"><img class="field__img" src="assets/wave-large.jpg" alt="A blue wave curling over" width="960" height="640"></a>
        <a class="field__print field__print--wide" href="#"><img class="field__img" src="assets/crater.jpg" alt="Purple desert flowers on dark rock" width="800" height="534"></a>
        <a class="field__print field__print--tall field__print--mono" href="#"><img class="field__img" src="assets/window.jpg" alt="A figure at a bright window" width="541" height="800"></a>
      </div>
    </div>
    <div class="field__col field__col--centre" data-speed="10" data-offset="0">
      <div class="field__track">
        <a class="field__print field__print--wide" href="#"><img class="field__img" src="assets/bathers.jpg" alt="Bathers on a grey beach" width="800" height="479"></a>
        <a class="field__print field__print--wide" href="#"><img class="field__img" src="assets/dunes-cadiz.jpg" alt="White flowers in desert sand" width="800" height="533"></a>
      </div>
    </div>
    <div class="field__col" data-speed="18" data-offset="260">
      <div class="field__track">
        <a class="field__print field__print--tall field__print--mono" href="#"><img class="field__img" src="assets/sitter.jpg" alt="An old portrait of a woman with long hair" width="634" height="800"></a>
        <a class="field__print field__print--wide" href="#"><img class="field__img" src="assets/barks.jpg" alt="Sailing boats under a storm sky" width="800" height="518"></a>
        <a class="field__print field__print--tall" href="#"><img class="field__img" src="assets/dunes-tall.jpg" alt="A dirt road toward pale hills" width="534" height="800"></a>
      </div>
    </div>
    <div class="field__col field__col--outer" data-speed="26" data-offset="300">
      <div class="field__track">
        <a class="field__print field__print--tall" href="#"><img class="field__img" src="assets/window.jpg" alt="A figure at a bright window" width="541" height="800"></a>
        <a class="field__print field__print--wide" href="#"><img class="field__img" src="assets/crater.jpg" alt="Purple desert flowers on dark rock" width="800" height="534"></a>
        <a class="field__print field__print--wide field__print--mono" href="#"><img class="field__img" src="assets/wave-large.jpg" alt="A blue wave curling over" width="960" height="640"></a>
      </div>
    </div>
  </div>
</section>

<style>
  .field {
    position: relative;
    height: var(--stage);
    overflow: hidden;
    background: var(--paper);
  }

  .field__plus {
    position: absolute;
    left: 50%;
    top: var(--space-m);
    z-index: 3;
    width: var(--cross);
    height: var(--cross);
    transform: translateX(-50%);
    pointer-events: none;
  }
  .field__plus::before,
  .field__plus::after {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: var(--rule);
    background: var(--ink);
  }
  .field__plus::after {
    transform: rotate(90deg);
  }

  /* The name sits under the prints: they are allowed to slide across it. */
  .field__name {
    position: absolute;
    inset: 50% var(--edge) auto;
    z-index: 1;
    margin: 0;
    transform: translateY(-50%);
    font-family: var(--font-display);
    font-size: var(--display-l);
    font-stretch: var(--stretch-display);
    font-weight: var(--weight-display);
    line-height: 1;
    letter-spacing: var(--track);
    text-align: center;
    text-transform: uppercase;
    text-wrap: balance;
  }

  /* Five columns, the outer two cut by the page edge. */
  .field__cols {
    position: absolute;
    inset: 0 -12%;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--gap);
  }
  .field__col {
    overflow: hidden;
  }
  .field__track {
    display: flex;
    flex-direction: column;
    align-items: center;
    will-change: transform;
  }
  .field__print {
    display: block;
    flex: none;
    margin-bottom: clamp(48px, 8vw, 128px);
    background: var(--shade);
    transition: opacity var(--fade) var(--ease-soft);
  }
  .field__col--centre .field__print {
    margin-bottom: clamp(220px, 30vw, 440px);
  }
  .field__col:nth-child(even) .field__print:nth-child(odd) { transform: translateX(-14%); }
  .field__col:nth-child(odd) .field__print:nth-child(even) { transform: translateX(12%); }
  .field__print--wide { width: var(--print-wide); aspect-ratio: 4 / 3; }
  .field__print--tall { width: var(--print-tall); aspect-ratio: 3 / 4; }
  .field__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter var(--fade) var(--ease-soft);
  }
  .field__print--mono .field__img { filter: grayscale(1) contrast(1.08); }

  .field__cols:hover .field__print { opacity: 0.28; }
  .field__cols .field__print:hover,
  .field__cols .field__print:focus-visible { opacity: 1; }
  .field__print:hover .field__img,
  .field__print:focus-visible .field__img { filter: none; }
  .field__print:focus-visible {
    outline: var(--rule) solid var(--ink);
    outline-offset: 4px;
  }

  @media (max-width: 640px) {
    .field__cols {
      inset: 0 -22%;
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .field__col--outer { display: none; }
    .field__name {
      inset: 50% 0 auto;
      max-width: 6.5em;
      margin-inline: auto;
      font-size: var(--display-xl);
    }
  }
</style>

<script>
  (() => {
    const reduce = window.matchMedia("(prefers-reduced-motion: reduce)");
    for (const root of document.querySelectorAll(".field")) {
      const cols = [...root.querySelectorAll(".field__col")].map((col) => {
        const track = col.querySelector(".field__track");
        for (const print of [...track.children]) {
          const copy = print.cloneNode(true);
          copy.setAttribute("aria-hidden", "true");
          copy.tabIndex = -1;
          track.append(copy);
        }
        return { col, track, speed: Number(col.dataset.speed) || 16, offset: Number(col.dataset.offset) || 0 };
      });

      const place = () => {
        for (const c of cols) {
          const half = c.track.scrollHeight / 2 || 1;
          c.track.style.transform = `translateY(${-(c.offset % half)}px)`;
        }
      };

      let pace = 1;
      let target = 1;
      let visible = false;
      let last = 0;
      let frame = 0;
      root.addEventListener("pointerenter", () => { target = 0.25; });
      root.addEventListener("pointerleave", () => { target = 1; });

      const tick = (now) => {
        const dt = Math.min(0.05, (now - last) / 1000 || 0);
        last = now;
        pace += (target - pace) * Math.min(1, dt * 4);
        for (const c of cols) c.offset += c.speed * pace * dt;
        place();
        frame = requestAnimationFrame(tick);
      };
      const start = () => {
        if (frame || reduce.matches || !visible) return;
        last = performance.now();
        frame = requestAnimationFrame(tick);
      };
      const stop = () => {
        cancelAnimationFrame(frame);
        frame = 0;
      };

      new IntersectionObserver(([entry]) => {
        visible = entry.isIntersecting;
        visible ? start() : stop();
      }).observe(root);
      reduce.addEventListener("change", () => (reduce.matches ? stop() : start()));
      place();
    }
  })();
</script>

Similar components

Numbered plate

Numbered plate

Threaded drag board

Threaded drag board

Framed still reel

Framed still reel

Statement with picture trail

Statement with picture trail

Grey stage

Grey stage

Portrait lineup

Portrait lineup

Drifting oval field

Drifting oval field

Tile ring hero

Tile ring hero