# Scroll Sequence

> A numbered series of pictures drawn on one canvas as the scroll runs through a section that holds the screen. Captions come in on cue, and the frames load coarse to fine: a fast scroll never shows a blank.

Scroll · scroll, image sequence, canvas, frames, sticky, scrub, product turn, 360 turn, storytelling · HTML, CSS, vanilla JS · no dependencies · updated 2026-11-06
Demo: https://kodza.dev/components/scroll-sequence/
Source on GitHub: https://github.com/kodza-dev/kodza/tree/main/components/scroll-sequence

Takes the whole screen (or reacts to the page scroll): give it a page, not a small box.

## Files

The code below, served as files: byte for byte what the Kodza site copies (the CSS includes its theme guard).

- [`kodza-scroll-sequence.css`](https://kodza.dev/registry/scroll-sequence/kodza-scroll-sequence.css) · 16.8 KB
- [`kodza-scroll-sequence.js`](https://kodza.dev/registry/scroll-sequence/kodza-scroll-sequence.js) · 15.8 KB
- [`kodza-scroll-sequence.html`](https://kodza.dev/registry/scroll-sequence/kodza-scroll-sequence.html) · 1.9 KB · the markup, to adapt and paste into your page

**Can you run shell commands? Download the CSS and the JS, don't retype them.** Retyping costs thousands of tokens and can drop or change lines of the CSS. Put the files where your stack expects them (Use it says where: change the `-o` paths):

```bash
curl -fsSL --create-dirs -o kodza/kodza-scroll-sequence.css https://kodza.dev/registry/scroll-sequence/kodza-scroll-sequence.css
curl -fsSL --create-dirs -o kodza/kodza-scroll-sequence.js https://kodza.dev/registry/scroll-sequence/kodza-scroll-sequence.js
```

Then load the files from your page as Use it shows, instead of pasting the content. The HTML is the part you adapt (text, links, modifiers): paste it from the Code section. Copy the CSS and the JS from the Code section only if you can't run commands, exactly as they are. (Windows PowerShell: `curl.exe`.)

**Its images are free to use in what you ship** (Kodza house images, Kodza License). The HTML loads them from kodza.dev, whose addresses can change: copy them into the project and point each `src` to the copy (a Claude artifact embeds them instead, as Use it says).

```bash
curl -fsSL --create-dirs -o kodza/media/kz-arch-day https://kodza.dev/media/kz-arch-day
```

## API

- Root: `[data-kodza-scroll-sequence]`
- Variables (set them on the root element itself: it declares its own defaults):
  - `--kz-scroll-sequence-distance: 300svh`
  - `--kz-scroll-sequence-fit: cover`
  - `--kz-scroll-sequence-position: 50% 50%`
  - `--kz-scroll-sequence-media-portrait: 56%`
  - `--kz-scroll-sequence-position-portrait: 83% 25%`
  - `--kz-scroll-sequence-gutter: clamp(20px, 5cqi, 72px)`
  - `--kz-scroll-sequence-sky: #e5e3e1`
  - `--kz-scroll-sequence-ink: var(--kz-color-ink, #0a0a0a)`
  - `--kz-scroll-sequence-muted: color-mix(in srgb, var(--kz-scroll-sequence-ink) 66%, transparent)`
  - `--kz-scroll-sequence-rail: color-mix(in srgb, var(--kz-scroll-sequence-ink) 18%, transparent)`
  - `--kz-scroll-sequence-radius: calc(16px * var(--kz-radius-scale, 1))`
  - `--kz-scroll-sequence-mono: var(--kz-font-mono, "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace)`
- Attributes:
  - `data-at` (e.g. `0`, `0.36`, `0.7`)
  - `data-frames` (e.g. `60`)
  - `data-kodza-scroll-sequence`
  - `data-pad`
  - `data-src` (e.g. `https://kodza.dev/media/kz-arch-day/{index}.webp`)
- Lifecycle: `kodza:init` / `kodza:destroy` on `document`, with `{ detail: { root } }` to target a container.

## Images

The shape of each image slot, measured in the demo at 1440 × 900 (desktop) and 390 × 844 (mobile). Where the shape is fixed, the frame crops the image to it: export in that shape, keep the subject near the centre, at twice the widest size shown (sharp on retina screens).

| Slot | Desktop | Mobile | Widest shown |
| --- | --- | --- | --- |
| `.kodza-scroll-sequence__poster` | 16:9 | 16:9 | 1080 px |

## Dark mode

The values Kodza uses on a dark background (`#0a0a0a`). For a page that follows the system theme, add them after the component's CSS:

```css
@media (prefers-color-scheme: dark) {
  .kodza-scroll-sequence {
    --kz-scroll-sequence-sky: #08080a;
    --kz-scroll-sequence-ink: #f2f2f0;
    --kz-scroll-sequence-muted: rgba(242, 242, 240, 0.66);
    --kz-scroll-sequence-rail: rgba(242, 242, 240, 0.22);
  }
}
```

A site with its own theme switch puts the same rules under its dark selector instead (`[data-theme="dark"] .kodza-scroll-sequence { … }`); a single dark section, under that section's class.

Its images have dark versions next to them (`kz-arch-day` → `kz-arch-day`). To swap them on a dark page: `<picture><source media="(prefers-color-scheme: dark)" srcset="…-dark-….webp"><img …></picture>`.

## Use it

### Plain HTML page

- CSS: `kodza/kodza-scroll-sequence.css` next to the page (the Files commands as they are), linked in `<head>`: `<link rel="stylesheet" href="kodza/kodza-scroll-sequence.css">`. Without a shell, paste it in a `<style>` in `<head>` instead. It only touches `kodza-` classes.
- HTML: where the component goes. Paste it as many times as you need: instances never interfere.
- JS: `kodza/kodza-scroll-sequence.js`, loaded with `<script src="kodza/kodza-scroll-sequence.js" defer></script>` in `<head>`. Without a shell, paste it in a `<script>` before `</body>` (or in `<head>`: it waits for the page). One copy per page, whatever the number of instances.
- Restyle with the `--kz-…` variables, set on the component's root element itself (the root declares its own defaults, so a value on an ancestor is ignored), and with the modifiers / attributes listed under API.
- Font: it takes the page's own. A site with its own type sets it once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-font-display`, the display face (headings, big numbers, wordmarks); `--kz-font-display-weight`, its weight; `--kz-font-display-scale`, a multiplier on its sizes (1 by default); `--kz-font-display-tracking`, its letter-spacing; `--kz-font-display-case`, its case (`uppercase`…); `--kz-font-label`, the face of the small labels (meta, captions, counters, hints, footer links, button labels); `--kz-font-label-size`, their size, one for all of them (`11px`…); `--kz-font-label-weight`, their weight; `--kz-font-label-tracking`, their letter-spacing; `--kz-font-label-case`, their case (`uppercase`…; code and units keep theirs); `--kz-font-label-leading`, their line-height (`1.45`…; buttons, pills and keys keep their box); `--kz-font-mono`, the monospace face (code, labels, counters). The Kodza look is Geist: `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap">`.
- Corners: a site with its own shapes sets them once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-radius-scale` multiplies every corner (`0` square, `0.5` softer, `1` Kodza); `--kz-radius-pill` sets the pills (`0` squares them).
- Motion: a site sets its pace once for every Kodza component, on `:root`, never by editing the CSS or the JS: `--kz-motion-scale` multiplies every duration (`0.5` twice as fast, `2` twice as slow, `0` no motion at all, loops stopped, like reduced motion). Unset, nothing changes.
- Content added later (AJAX navigation, a SPA route, a builder preview): start it with `document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root: container } }))`; before removing it, the same call with `'kodza:destroy'` stops it and puts the original markup back.

### Claude artifact (claude.ai)

- Paste the CSS in a `<style>` and the JS in a `<script>` at the end, in the artifact itself: it loads stylesheets only from Google Fonts and scripts only from a few CDNs, so no `<link>` or `<script src>` to Kodza.
- Writing the artifact file with a shell? Insert the downloaded files (Files) with a command instead of retyping them: a line `KODZA-CSS` alone inside the `<style>`, `KODZA-JS` inside the `<script>`, then `sed -e '/^KODZA-CSS$/{r kodza/kodza-scroll-sequence.css' -e 'd' -e '}' -e '/^KODZA-JS$/{r kodza/kodza-scroll-sequence.js' -e 'd' -e '}' page.html > artifact.html`.
- Font: load Geist from Google Fonts (allowed): `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap">`. A site with its own type sets it once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-font-display`, the display face (headings, big numbers, wordmarks); `--kz-font-display-weight`, its weight; `--kz-font-display-scale`, a multiplier on its sizes (1 by default); `--kz-font-display-tracking`, its letter-spacing; `--kz-font-display-case`, its case (`uppercase`…); `--kz-font-label`, the face of the small labels (meta, captions, counters, hints, footer links, button labels); `--kz-font-label-size`, their size, one for all of them (`11px`…); `--kz-font-label-weight`, their weight; `--kz-font-label-tracking`, their letter-spacing; `--kz-font-label-case`, their case (`uppercase`…; code and units keep theirs); `--kz-font-label-leading`, their line-height (`1.45`…; buttons, pills and keys keep their box); `--kz-font-mono`, the monospace face (code, labels, counters).
- Corners: a site with its own shapes sets them once for every Kodza component, on `:root`, never by editing the CSS (unset, nothing changes): `--kz-radius-scale` multiplies every corner (`0` square, `0.5` softer, `1` Kodza); `--kz-radius-pill` sets the pills (`0` squares them).
- Motion: a site sets its pace once for every Kodza component, on `:root`, never by editing the CSS or the JS: `--kz-motion-scale` multiplies every duration (`0.5` twice as fast, `2` twice as slow, `0` no motion at all, loops stopped, like reduced motion). Unset, nothing changes.
- Images: the artifact blocks every other host, `kodza.dev` included, without an error. Embed each one as a `data:` URI, with a command if you can run one (`curl -s <url> | base64`; the 1400 px files weigh 10 to 30 KB), never by typing base64 out. If you can't run commands, keep the `<img>` with its `width` and `height`, and tell the user the picture stays blank inside the artifact.
- Dark mode: the viewer sets `data-theme="dark"` or `"light"` on `<html>`, or nothing when it follows the system. Write the Dark mode rules twice: inside `@media (prefers-color-scheme: dark)` with `:root:not([data-theme="light"])` in front of each selector, and with `:root[data-theme="dark"]` in front of each selector.

### WordPress

- HTML: a **Custom HTML** block (or a pattern / template part). WordPress keeps this markup as it is only for users allowed to post unfiltered HTML (Administrators; Super Admins on multisite): for anyone else it strips tags such as `<svg>`, `<input>` or `<dialog>`, so add it from the theme (a pattern or template part) instead.
- This one spans the page: a block theme keeps a Custom HTML block to the width of the text column, so put it inside a **Group** block set to **Full width**, with **Inner blocks use content width** turned off.
- CSS and JS: the downloaded files go in the theme, under `wp-content/themes/<your-theme>/kodza/` (the child theme if there is one), enqueued from its functions.php (or a code-snippets plugin):
  ```php
  add_action('wp_enqueue_scripts', function () {
    $dir = get_stylesheet_directory() . '/kodza/';
    $uri = get_stylesheet_directory_uri() . '/kodza/';
    wp_enqueue_style('kodza-scroll-sequence', $uri . 'kodza-scroll-sequence.css', [], filemtime($dir . 'kodza-scroll-sequence.css'));
    wp_enqueue_script('kodza-scroll-sequence', $uri . 'kodza-scroll-sequence.js', [], filemtime($dir . 'kodza-scroll-sequence.js'), true);
  });
  ```
  Scoped to `kodza-` classes, the CSS never touches the theme. One copy of the JS, whatever the number of blocks.
- No access to the theme files? The CSS can also go, as it is, in **Appearance → Customize → Additional CSS** (classic theme) or **Styles → Additional CSS** in the Site Editor (block theme).
- Theme with AJAX page transitions: fire `kodza:init` on the new content after each swap (and `kodza:destroy` on the old one).
- Performance plugin (WP Rocket, LiteSpeed Cache, Perfmatters…) with **Delay JavaScript execution** turned on: add `kodza` to the scripts it must not delay. Otherwise the component waits for the visitor's first scroll, tap or mouse move, and that first click can be lost.
- Colours: it takes the colour of the text around it (or keeps its own monochrome): nothing to point at the theme.
- WordPress turns straight quotes and `--` into typographic ones in the text of a Custom HTML block (not inside `<code>` or `<pre>`).

#### With Elementor

- HTML: an **HTML** widget (Elementor shows it to administrators only). It keeps the code exactly as pasted, straight quotes included.
- This one spans the page: give the widget its own container, **Content Width: Full Width**, padding 0.
- CSS and JS: as above. Elementor's Site Settings → Theme Style styles every button, field, link and image of the page, components included; the theme guard at the end of the CSS keeps the component's buttons, fields and link colours as they are.
- The Elementor editor redraws each widget after the page has loaded: without the script below, the component stays still in the editor preview (the published page works). Add it once per site, in the footer like the component's script (`kodza/elementor-editor.js`, or a code-snippets plugin):

```js
// Kodza in the Elementor editor: the editor redraws each HTML widget after the page has loaded.
// Start Kodza in what it draws, stop it in what it replaces or removes. Once per site.
window.addEventListener('elementor/frontend/init', () => {
  if (!elementorFrontend.isEditMode()) return;
  class KodzaWidget extends elementorModules.frontend.handlers.Base {
    onInit() {
      super.onInit();
      this.kodza = [...this.$element[0].children];
      document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root: this.$element[0] } }));
    }
    onDestroy() {
      super.onDestroy();
      this.kodza.forEach((root) => document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } })));
    }
  }
  elementorFrontend.elementsHandler.attachHandler('html', KodzaWidget);
});
```

- No child theme: everything can go in the HTML widget instead, `<style>` with the CSS, the HTML, then `<script>` with the JS. It works on the page and in the editor without the script above.

### Shopify

- Files: `assets/kodza-scroll-sequence.css` and `assets/kodza-scroll-sequence.js` (the Files commands with `-o assets/…`).
- In the section: `{{ 'kodza-scroll-sequence.css' | asset_url | stylesheet_tag }}` and `<script src="{{ 'kodza-scroll-sequence.js' | asset_url }}" defer></script>`, then the HTML.
- The theme editor re-renders sections: restart them with
  `document.addEventListener('shopify:section:load', (e) => document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root: e.target } })));`
  and the same with `shopify:section:unload` → `kodza:destroy`.

### React / Next.js

- Files, side by side (e.g. in `components/kodza/`): `ScrollSequence.tsx` (below), the CSS block under Code saved as `scroll-sequence.css` and the JS block as `scroll-sequence.js`, both as they are. The HTML block is already inside the component: skip it.
- Use it: `import { ScrollSequence } from '@/components/kodza/ScrollSequence';` then `<ScrollSequence />`. Props: `frames` (`data-frames`: "60"), `src` (`data-src`: "https://kodza.dev/media/kz-arch-day/{index}.webp"), `vars` (the `--kz-…` variables listed under API, e.g. `vars={{ '--kz-scroll-sequence-distance': … }}`), `className`, `style` and the other props of its `<div>` (`onClick`, `aria-…`).
- Next.js App Router: it is a Client Component already (`'use client'`). Pages Router: Next.js takes global CSS only in `pages/_app`, so move the `import './scroll-sequence.css'` line there.
- Safe under StrictMode, client-side navigation and prop changes: when a prop changes, the `key` gives React a fresh element, `kodza:destroy` stops the script on the old one and `kodza:init` starts it on the new one.
- Built from your data (tabs, rows, options)? Add what the markup is made of to the `key`, as plain values (ids, text, numbers). What the visitor changes (the open tab, the sort, what they type) is the script's: follow it with `onClick` or `onInput` on the root, and change it from your code as a visitor would (click the tab; set the field's value, then dispatch a bubbling `input` event). Fields stay uncontrolled (`defaultValue`, `name`).

```tsx
'use client';
// Kodza — Scroll Sequence, for React. From https://kodza.dev/components/scroll-sequence/
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Next to this file: scroll-sequence.css and scroll-sequence.js, the component's CSS and JS from Kodza, as they are.
// Yours to edit: the markup is plain JSX below.
// The script changes this markup once React has rendered it (it adds layers, splits text, moves
// nodes), so React must not patch it afterwards. When a prop changes, the key gives React a fresh
// element: kodza:destroy stops the script on the old one, kodza:init starts it on the new one.
// data-kodza-manual keeps the script from starting it on its own: the effect below does, once
// React has hydrated the markup (on a page that streams in, the script can load first).
// Built from your data (tabs, rows, options)? Put what the markup is made of in the key, as plain
// values (ids, text, numbers): a change starts the script again on fresh markup. What the visitor
// changes (the open tab, the sort, what they type) is the script's: keep it out of the key, follow
// it with onClick or onInput on the root, and change it from your code as a visitor would (click
// the tab; set the field's value, then dispatch a bubbling input event).
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './scroll-sequence.css';

export type ScrollSequenceProps = Omit<ComponentPropsWithoutRef<'div'>, "children" | "vars" | "frames" | "src"> & {
  /** data-frames on the root (default: 60) */
  frames?: "60";
  /** data-src on the root (default: https://kodza.dev/media/kz-arch-day/{index}.webp) */
  src?: "https://kodza.dev/media/kz-arch-day/{index}.webp";
  /** Settings, as CSS variables on the root */
  vars?: {
    /** default: 300svh */
    "--kz-scroll-sequence-distance"?: string | number;
    /** default: cover */
    "--kz-scroll-sequence-fit"?: string | number;
    /** default: 50% 50% */
    "--kz-scroll-sequence-position"?: string | number;
    /** default: 56% */
    "--kz-scroll-sequence-media-portrait"?: string | number;
    /** default: 83% 25% */
    "--kz-scroll-sequence-position-portrait"?: string | number;
    /** default: clamp(20px, 5cqi, 72px) */
    "--kz-scroll-sequence-gutter"?: string | number;
    /** default: #e5e3e1 */
    "--kz-scroll-sequence-sky"?: string | number;
    /** default: var(--kz-color-ink, #0a0a0a) */
    "--kz-scroll-sequence-ink"?: string | number;
    /** default: color-mix(in srgb, var(--kz-scroll-sequence-ink) 66%, transparent) */
    "--kz-scroll-sequence-muted"?: string | number;
    /** default: color-mix(in srgb, var(--kz-scroll-sequence-ink) 18%, transparent) */
    "--kz-scroll-sequence-rail"?: string | number;
    /** default: calc(16px * var(--kz-radius-scale, 1)) */
    "--kz-scroll-sequence-radius"?: string | number;
    /** default: var(--kz-font-mono, "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace) */
    "--kz-scroll-sequence-mono"?: string | number;
  };
  className?: string;
};

export function ScrollSequence({ frames = "60", src = "https://kodza.dev/media/kz-arch-day/{index}.webp", vars, className, style, ...rest }: ScrollSequenceProps) {
  const ref = useRef<ComponentRef<'div'>>(null);
  const classes = ["kodza-scroll-sequence", className].filter(Boolean).join(' ');
  // Everything the markup is made of: when it changes, React gets a fresh element (see the top)
  const key = JSON.stringify([classes, frames, src, vars, style, rest]);

  // Starts the script on this element once React has rendered it, stops it when it goes
  useEffect(() => {
    const root = ref.current;
    let live = true;
    // @ts-ignore: a plain script, no types to find
    import('./scroll-sequence.js').then(() => {
      if (live) document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root } }));
    });
    return () => {
      live = false;
      document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } }));
    };
  }, [key]);

  return (
    <div data-kodza-scroll-sequence="" key={key} {...rest} className={classes} data-kodza-manual data-frames={frames} data-src={src} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
      <div className="kodza-scroll-sequence__stage">
        <img className="kodza-scroll-sequence__poster" src="https://kodza.dev/media/kz-arch-day/01.webp" alt="A concrete wall with a single arched opening, its patch of sunlight crossing the ground from morning to evening" width="1440" height="810" />
        <div className="kodza-scroll-sequence__panel">
          <p className="kodza-scroll-sequence__meter" aria-hidden="true">
            <span className="kodza-scroll-sequence__counter">01 / 60</span>
            {' '}
            <span className="kodza-scroll-sequence__rail" />
          </p>
          <div className="kodza-scroll-sequence__captions">
            <div className="kodza-scroll-sequence__caption" data-at="0">
              <p className="kodza-scroll-sequence__label">Le Mur — Étretat, 8:10</p>
              <h2 className="kodza-scroll-sequence__title">One wall. One hole.</h2>
              <p className="kodza-scroll-sequence__text">Poured on the cliff path, facing inland. Nobody moves in this film, and neither does the camera. Only the sun does.</p>
            </div>
            <div className="kodza-scroll-sequence__caption" data-at="0.36">
              <p className="kodza-scroll-sequence__label">Noon — sun 38° up</p>
              <h2 className="kodza-scroll-sequence__title">The patch crosses the slab.</h2>
              <p className="kodza-scroll-sequence__text">The sun climbs and the light through the arch slides across the ground. A sundial nobody asked for.</p>
            </div>
            <div className="kodza-scroll-sequence__caption" data-at="0.7">
              <p className="kodza-scroll-sequence__label">Evening — sun 14° up</p>
              <h2 className="kodza-scroll-sequence__title">Then the wall takes it back.</h2>
              <p className="kodza-scroll-sequence__text">Low sun, long shadow. By seven the opening is just a door again, and the scroll gives you the morning back.</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}
```

## Code

```html
<div class="kodza-scroll-sequence" data-kodza-scroll-sequence data-frames="60" data-src="https://kodza.dev/media/kz-arch-day/{index}.webp">
  <div class="kodza-scroll-sequence__stage">
    <img class="kodza-scroll-sequence__poster" src="https://kodza.dev/media/kz-arch-day/01.webp" alt="A concrete wall with a single arched opening, its patch of sunlight crossing the ground from morning to evening" width="1440" height="810">
    <div class="kodza-scroll-sequence__panel">
      <p class="kodza-scroll-sequence__meter" aria-hidden="true">
        <span class="kodza-scroll-sequence__counter">01 / 60</span>
        <span class="kodza-scroll-sequence__rail"></span>
      </p>
      <div class="kodza-scroll-sequence__captions">
        <div class="kodza-scroll-sequence__caption" data-at="0">
          <p class="kodza-scroll-sequence__label">Le Mur — Étretat, 8:10</p>
          <h2 class="kodza-scroll-sequence__title">One wall. One hole.</h2>
          <p class="kodza-scroll-sequence__text">Poured on the cliff path, facing inland. Nobody moves in this film, and neither does the camera. Only the sun does.</p>
        </div>
        <div class="kodza-scroll-sequence__caption" data-at="0.36">
          <p class="kodza-scroll-sequence__label">Noon — sun 38° up</p>
          <h2 class="kodza-scroll-sequence__title">The patch crosses the slab.</h2>
          <p class="kodza-scroll-sequence__text">The sun climbs and the light through the arch slides across the ground. A sundial nobody asked for.</p>
        </div>
        <div class="kodza-scroll-sequence__caption" data-at="0.7">
          <p class="kodza-scroll-sequence__label">Evening — sun 14° up</p>
          <h2 class="kodza-scroll-sequence__title">Then the wall takes it back.</h2>
          <p class="kodza-scroll-sequence__text">Low sun, long shadow. By seven the opening is just a door again, and the scroll gives you the morning back.</p>
        </div>
      </div>
    </div>
  </div>
</div>
```

```css
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Scroll Sequence
   A numbered series of pictures (a turn around an object, an assembly, a time lapse) drawn on one
   canvas, frame by frame, as the scroll runs through the section. The stage holds the screen,
   the captions roll in at their own point of the sequence, and a rail with a frame counter says
   where you are. No video file: the frames are plain images, loaded coarse to fine.
   Without the script, or with reduced motion, the first picture sits above the captions.
   Tuned with the --kz-scroll-sequence-* variables; the frames are set on the root
   (data-frames, data-src, data-pad), the pacing in the constants at the top of component.js. */
.kodza-scroll-sequence {
  /* How much scroll the whole sequence takes, on top of the screen the stage holds */
  --kz-scroll-sequence-distance: 300svh;
  /* How the frames fill the stage, and which part of them a crop keeps */
  --kz-scroll-sequence-fit: cover;
  --kz-scroll-sequence-position: 50% 50%;
  /* On a tall screen (a phone, a tablet, a narrow window) the frames sit in a box at the bottom,
     under the captions: its share of the stage's height (at most a square), and the part of the
     frames it keeps */
  --kz-scroll-sequence-media-portrait: 56%;
  --kz-scroll-sequence-position-portrait: 83% 25%;
  /* The room kept around the captions and the rail */
  --kz-scroll-sequence-gutter: clamp(20px, 5cqi, 72px);
  /* The colour behind the frames: match the sky of your pictures, so a portrait screen reads as
     one picture with a tall sky */
  --kz-scroll-sequence-sky: #e5e3e1;
  --kz-scroll-sequence-ink: var(--kz-color-ink, #0a0a0a);
  --kz-scroll-sequence-muted: color-mix(in srgb, var(--kz-scroll-sequence-ink) 66%, transparent);
  --kz-scroll-sequence-rail: color-mix(in srgb, var(--kz-scroll-sequence-ink) 18%, transparent);
  --kz-scroll-sequence-radius: calc(16px * var(--kz-radius-scale, 1));
  --kz-scroll-sequence-mono: var(--kz-font-mono, "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace);

  position: relative;
  display: block;
  container-type: inline-size;
  color: var(--kz-scroll-sequence-ink);
}

/* At rest (no script, reduced motion): the first picture, the captions under it */
.kodza-scroll-sequence__stage {
  box-sizing: border-box;
  display: grid;
  gap: 32px;
  width: min(1080px, 100% - 2 * var(--kz-scroll-sequence-gutter));
  margin-inline: auto;
}

.kodza-scroll-sequence__poster {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  margin: 0;
  border-radius: var(--kz-scroll-sequence-radius);
  background: var(--kz-scroll-sequence-sky);
  aspect-ratio: 16 / 9;
  object-fit: var(--kz-scroll-sequence-fit);
  object-position: var(--kz-scroll-sequence-position);
}

.kodza-scroll-sequence__panel {
  display: grid;
  gap: 28px;
}

/* The frame counter and the rail: only while the frames follow the scroll */
.kodza-scroll-sequence__meter {
  display: none;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin: 0;
}

.kodza-scroll-sequence__captions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 28px;
}

.kodza-scroll-sequence__caption {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.kodza-scroll-sequence__label,
.kodza-scroll-sequence__counter {
  margin: 0;
  color: var(--kz-scroll-sequence-muted);
  font-family: var(--kz-font-label, var(--kz-scroll-sequence-mono));
  font-size: var(--kz-font-label-size, 12.5px);
  font-weight: var(--kz-font-label-weight, 500);
  line-height: var(--kz-font-label-leading, 1.4);
  letter-spacing: var(--kz-font-label-tracking, 0.02em);
  text-transform: var(--kz-font-label-case, inherit);
}

.kodza-scroll-sequence__title {
  margin: 0;
  color: inherit;
  font-family: var(--kz-font-display, inherit);
  font-size: calc(clamp(28px, 3.6cqi, 52px) * var(--kz-font-display-scale, 1));
  font-weight: var(--kz-font-display-weight, 600);
  line-height: 1.02;
  letter-spacing: var(--kz-font-display-tracking, -0.045em);
  text-transform: var(--kz-font-display-case, inherit);
  text-wrap: balance;
}

/* At rest the captions share a row: a smaller title keeps each to two lines, and the label, title
   and text rows line up across the columns */
.kodza-scroll-sequence:not(.is-live) .kodza-scroll-sequence__title {
  font-size: calc(clamp(24px, 2.6cqi, 34px) * var(--kz-font-display-scale, 1));
}

.kodza-scroll-sequence:not(.is-live) .kodza-scroll-sequence__caption {
  grid-row: span 3;
  grid-template-rows: subgrid;
}

.kodza-scroll-sequence__text {
  max-width: 30em;
  margin: 0;
  color: var(--kz-scroll-sequence-muted);
  font-size: 16px;
  line-height: 1.55;
  text-wrap: pretty;
}

/* Running: the section is a track, the stage holds the screen while the scroll runs through it */
.kodza-scroll-sequence.is-live::after {
  content: "";
  display: block;
  height: var(--kz-scroll-sequence-distance);
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__stage {
  position: sticky;
  top: 0;
  display: block;
  width: auto;
  height: 100svh;
  overflow: clip;
  background: var(--kz-scroll-sequence-sky);
  container: kodza-scroll-sequence / size;
}

/* The picture under the canvas until the first frame is drawn, then the canvas over it */
.kodza-scroll-sequence.is-live .kodza-scroll-sequence__poster,
.kodza-scroll-sequence__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
  border-radius: 0;
  aspect-ratio: auto;
  object-fit: var(--kz-scroll-sequence-fit);
  object-position: var(--kz-scroll-sequence-position);
}

/* Once a frame is drawn, the picture steps back (still read out: its alt names the sequence) */
.kodza-scroll-sequence.is-drawn .kodza-scroll-sequence__poster {
  opacity: 0;
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__panel {
  position: absolute;
  top: clamp(28px, 9cqh, 96px);
  left: var(--kz-scroll-sequence-gutter);
  width: min(420px, 34cqw);
  gap: clamp(20px, 4cqh, 36px);
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__meter {
  display: grid;
}

.kodza-scroll-sequence__counter {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The rail: it fills with the scroll (--kz-scroll-sequence-progress, 0 to 1), and a dot marks
   where each caption comes in, inked once passed */
.kodza-scroll-sequence__rail {
  position: relative;
  display: block;
  height: 1px;
  background: var(--kz-scroll-sequence-rail);
}

.kodza-scroll-sequence__rail::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--kz-scroll-sequence-ink);
  transform: scaleX(var(--kz-scroll-sequence-progress, 0));
  transform-origin: left center;
}

.kodza-scroll-sequence__tick {
  position: absolute;
  top: 50%;
  left: calc(var(--kz-scroll-sequence-at, 0) * 100%);
  box-sizing: border-box;
  width: 7px;
  height: 7px;
  border: 1px solid var(--kz-scroll-sequence-rail);
  border-radius: var(--kz-radius-pill, 999px);
  background: var(--kz-scroll-sequence-sky);
  transform: translate(-50%, -50%);
  transition: background-color calc(0.2s * var(--kz-motion-scale, 1)) ease, border-color calc(0.2s * var(--kz-motion-scale, 1)) ease;
}

.kodza-scroll-sequence__tick:first-child {
  transform: translate(0, -50%);
}

.kodza-scroll-sequence__tick.is-passed {
  border-color: var(--kz-scroll-sequence-ink);
  background: var(--kz-scroll-sequence-ink);
}

/* The captions share one cell. The one on now stands; the next waits below, the last one has
   gone up: scrolling on rolls them up, scrolling back rolls them down */
.kodza-scroll-sequence.is-live .kodza-scroll-sequence__captions {
  grid-template-columns: minmax(0, 1fr);
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption {
  grid-area: 1 / 1;
  pointer-events: none;
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption > * {
  opacity: 0;
  transform: translateY(18px);
  /* Leaving: it fades as it slides, on the same curve, so the way out reads */
  transition: opacity calc(0.24s * var(--kz-motion-scale, 1)) cubic-bezier(0.4, 0, 1, 1), transform calc(0.24s * var(--kz-motion-scale, 1)) cubic-bezier(0.4, 0, 1, 1);
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption.is-past > * {
  transform: translateY(-18px);
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption.is-current {
  pointer-events: auto;
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption.is-current > * {
  opacity: 1;
  transform: none;
  transition: opacity calc(0.5s * var(--kz-motion-scale, 1)) ease, transform calc(0.7s * var(--kz-motion-scale, 1)) cubic-bezier(0.22, 1, 0.36, 1);
  /* In once the last one is nearly gone, so two titles never stand over each other */
  transition-delay: calc(0.16s * var(--kz-motion-scale, 1));
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption.is-current > :nth-child(2) {
  transition-delay: calc(0.2s * var(--kz-motion-scale, 1));
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption.is-current > :nth-child(n + 3) {
  transition-delay: calc(0.24s * var(--kz-motion-scale, 1));
}

/* A tall stage (a phone, a tablet, a 4:3 window): the captions on top, the frames in a box at the
   bottom that fades into the sky above it. Side by side, the captions would cover the subject. On
   a wide one (4:3) the box grows to the whole height of a 16:9 frame, as far as the captions let
   it, so nothing of the subject is cut at the bottom */
@container kodza-scroll-sequence (max-aspect-ratio: 14 / 9) {
  .kodza-scroll-sequence.is-live .kodza-scroll-sequence__poster,
  .kodza-scroll-sequence__canvas {
    top: auto;
    height: min(max(var(--kz-scroll-sequence-media-portrait), 56.25cqw), 100cqh - 190px, 100cqw);
    object-position: var(--kz-scroll-sequence-position-portrait);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%);
    mask-image: linear-gradient(to bottom, transparent, #000 12%);
  }

  .kodza-scroll-sequence.is-live .kodza-scroll-sequence__panel {
    top: clamp(20px, 4cqh, 40px);
    right: var(--kz-scroll-sequence-gutter);
    width: auto;
    max-width: 520px;
  }
}

/* kodza-guard f3278ebfb1a9 — generated by Kodza, do not edit.
   Theme guard: keeps a site's own CSS (WordPress themes, Bootstrap, CSS resets…) off this
   component. :not(#_) is always true and weighs as much as an id, so these lines win over
   theme rules made of classes and tags. Customise the component through its --kz-* variables. */

/* What the browser gives, where the component sets it only in some states: at the lowest weight, so its own rules below put it back */

:where(.kodza-scroll-sequence__poster):not(#_) {
  position: revert;
}

:where(.kodza-scroll-sequence__label):not(#_),
:where(.kodza-scroll-sequence__title):not(#_),
:where(.kodza-scroll-sequence__text):not(#_) {
  transition: revert;
}

/* What the browser gives, on everything the component leaves to it */

.kodza-scroll-sequence:not(#_),
.kodza-scroll-sequence__canvas:not(#_),
.kodza-scroll-sequence__panel:not(#_),
.kodza-scroll-sequence__counter:not(#_),
.kodza-scroll-sequence__rail:not(#_),
.kodza-scroll-sequence__captions:not(#_),
.kodza-scroll-sequence__caption:not(#_) {
  box-sizing: revert;
}

.kodza-scroll-sequence__poster:not(#_) {
  border: revert;
  padding: revert;
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-height: revert;
  color: revert;
  font-family: revert;
  font-size: revert;
  font-weight: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-sequence__meter:not(#_) {
  border: revert;
  padding: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  transition: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  color: revert;
  font-family: revert;
  font-size: revert;
  font-weight: revert;
  font-style: revert;
  line-height: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-sequence__label:not(#_),
.kodza-scroll-sequence__title:not(#_) {
  border: revert;
  padding: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-width: revert;
  max-height: revert;
  font-style: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-sequence__text:not(#_) {
  border: revert;
  padding: revert;
  border-radius: revert;
  outline: revert;
  text-decoration: revert;
  list-style: revert;
  box-sizing: revert;
  float: revert;
  position: revert;
  background-color: revert;
  background-image: revert;
  box-shadow: revert;
  outline-offset: revert;
  appearance: revert;
  max-height: revert;
  font-family: revert;
  font-weight: revert;
  font-style: revert;
  letter-spacing: revert;
  text-transform: revert;
  text-underline-offset: revert;
  text-align: revert;
  text-indent: revert;
  text-shadow: revert;
  vertical-align: revert;
}

.kodza-scroll-sequence__label:not(#_):where(:not([hidden])),
.kodza-scroll-sequence__title:not(#_):where(:not([hidden])),
.kodza-scroll-sequence__text:not(#_):where(:not([hidden])) {
  display: revert;
}

.kodza-scroll-sequence__label:not(#_):where([hidden]),
.kodza-scroll-sequence__title:not(#_):where([hidden]),
.kodza-scroll-sequence__text:not(#_):where([hidden]) {
  display: none;
}

.kodza-scroll-sequence:not(#_)::after,
.kodza-scroll-sequence__rail:not(#_)::before {
  box-sizing: revert;
}

/* The component's own rules, one step stronger: real buttons and fields, what it sets on tags themes style (links, lists, headings, images…), and the root width (a theme may narrow it, never widen it) */

.kodza-scroll-sequence__poster:not(#_) {
  display: block;
  max-width: none;
  margin: 0;
  border-radius: var(--kz-scroll-sequence-radius);
  background: var(--kz-scroll-sequence-sky);
}

.kodza-scroll-sequence__meter:not(#_) {
  display: none;
  margin: 0;
}

.kodza-scroll-sequence__label:not(#_) {
  margin: 0;
  color: var(--kz-scroll-sequence-muted);
  font-family: var(--kz-font-label, var(--kz-scroll-sequence-mono));
  font-size: var(--kz-font-label-size, 12.5px);
  font-weight: var(--kz-font-label-weight, 500);
  line-height: var(--kz-font-label-leading, 1.4);
  letter-spacing: var(--kz-font-label-tracking, 0.02em);
  text-transform: var(--kz-font-label-case, inherit);
}

.kodza-scroll-sequence__title:not(#_) {
  margin: 0;
  color: inherit;
  font-family: var(--kz-font-display, inherit);
  font-size: calc(clamp(28px, 3.6cqi, 52px) * var(--kz-font-display-scale, 1));
  font-weight: var(--kz-font-display-weight, 600);
  line-height: 1.02;
  letter-spacing: var(--kz-font-display-tracking, -0.045em);
  text-transform: var(--kz-font-display-case, inherit);
}

.kodza-scroll-sequence:not(.is-live) .kodza-scroll-sequence__title:not(#_) {
  font-size: calc(clamp(24px, 2.6cqi, 34px) * var(--kz-font-display-scale, 1));
}

.kodza-scroll-sequence__text:not(#_) {
  max-width: 30em;
  margin: 0;
  color: var(--kz-scroll-sequence-muted);
  font-size: 16px;
  line-height: 1.55;
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__poster:not(#_) {
  position: absolute;
  display: block;
  max-width: none;
  margin: 0;
  border-radius: 0;
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__meter:not(#_) {
  display: grid;
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption > *:not(#_) {
  transition: opacity calc(0.24s * var(--kz-motion-scale, 1)) cubic-bezier(0.4, 0, 1, 1), transform calc(0.24s * var(--kz-motion-scale, 1)) cubic-bezier(0.4, 0, 1, 1);
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption.is-current > *:not(#_) {
  transition: opacity calc(0.5s * var(--kz-motion-scale, 1)) ease, transform calc(0.7s * var(--kz-motion-scale, 1)) cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: calc(0.16s * var(--kz-motion-scale, 1));
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption.is-current > :nth-child(2):not(#_) {
  transition-delay: calc(0.2s * var(--kz-motion-scale, 1));
}

.kodza-scroll-sequence.is-live .kodza-scroll-sequence__caption.is-current > :nth-child(n + 3):not(#_) {
  transition-delay: calc(0.24s * var(--kz-motion-scale, 1));
}
```

```js
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Scroll Sequence
// The section becomes a track: its stage holds the screen while the scroll runs through it, and the
// script draws the frame that matches the scroll on one canvas. The frames load coarse to fine
// (every eighth first, then the ones between), so a fast scroll shows the nearest frame already
// there, never a blank. Each caption comes in at its own point (data-at, 0 to 1), the rail fills
// and the counter counts. The frames are set on the root: data-frames (how many), data-src (their
// address, {index} standing for 01, 02…) and data-pad (the digits of {index}, those of
// data-frames by default). The pacing is in the constants below. Reduced motion, or a site pace
// of 0: the first picture sits above the captions, and nothing loads.
(() => {
  const SELECTOR = '[data-kodza-scroll-sequence]';
  // The order the frames load in: every 8th, then every 4th, every 2nd, the rest
  const PASSES = [8, 4, 2, 1];
  // How many frames load at once
  const PARALLEL = 6;
  // The frames start loading this far ahead of the section (a share of the screen)
  const AHEAD = '100%';
  // How long the sequence takes to catch up with the scroll, in ms (times the site's pace), in two
  // soft stages like a smooth-scroll library: it picks up gently, and when the wheel stops it slows
  // down on its own instead of stopping with it. 0 glues it to the wheel
  const SMOOTHING = 170;
  // While the scroll runs, the picture blends the two frames around its exact place, so the turn
  // moves on every screen refresh instead of frame by frame. Once the scroll has stood still this
  // long, in ms, it settles on the next whole frame the way it was turning (never back, so it does
  // not shiver as you stop): never a double picture at rest
  const REST = 120;
  // The progress left to travel below this ends the loop
  const SETTLE = 0.0005;

  const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  // The site's pace, --kz-motion-scale (set on :root, read on the instance): every duration of the
  // script times it, and 0 moves nothing, like reduced motion
  const paceOf = (el) => {
    const pace = parseFloat(getComputedStyle(el).getPropertyValue('--kz-motion-scale'));
    return pace >= 0 ? pace : 1;
  };
  const clamp = (value, min, max) => Math.min(max, Math.max(min, value));

  // One instance, with its own state: two copies on a page never interfere. Everything it
  // starts is tied to `signal` (listeners get { signal }, observers and timers stop on its
  // 'abort' event), so kodza:destroy stops it all.
  function mount(root, signal) {
    const stage = root.querySelector('.kodza-scroll-sequence__stage');
    const poster = root.querySelector('.kodza-scroll-sequence__poster');
    const counter = root.querySelector('.kodza-scroll-sequence__counter');
    const rail = root.querySelector('.kodza-scroll-sequence__rail');
    const captions = [...root.querySelectorAll('.kodza-scroll-sequence__caption')];
    const frames = parseInt(root.dataset.frames, 10) || 0;
    const pace = paceOf(root);
    const still = reduceMotion || !pace; // the still path: no motion asked, by the visitor or the site
    if (still || !stage || frames < 2 || !root.dataset.src?.includes('{index}')) return;
    const smoothing = SMOOTHING * pace;
    const digits = String(frames).length;
    const pad = parseInt(root.dataset.pad, 10) || digits;
    const at = captions.map((caption) => clamp(parseFloat(caption.dataset.at) || 0, 0, 1));
    const total = String(frames).padStart(digits, '0');

    // A dot on the rail where each caption comes in
    const ticks = at.map((point) => {
      const tick = document.createElement('span');
      tick.className = 'kodza-scroll-sequence__tick';
      tick.style.setProperty('--kz-scroll-sequence-at', point);
      rail?.append(tick);
      return tick;
    });
    root.classList.add('is-live');

    const images = new Array(frames).fill(null);
    const loading = new Set();
    let order = [];
    let next = 0;
    let canvas = null;
    let context = null;
    let drawn = -1; // what the canvas shows: a frame, plus the share of the next one over it
    let picture = null; // the place in the sequence drawn: between two frames while it runs
    let leading = null; // the first stage of each glide, the one `current` and `picture` follow
    let turning = null;
    let index = 0; // the frame the scroll asks for
    let target = null; // the progress the scroll asks for, when it last changed, and which way
    let moved = 0;
    let way = 1;
    let held = null; // the whole frame it settled on, kept until the scroll goes past it
    let on = -1; // the caption on now
    let current = null; // the progress written now
    let raf = 0;
    let last = 0;
    let shown = false;

    // The frame asked for if it is there, or the nearest one loaded, the earlier one first
    const nearest = (wanted) => {
      for (let distance = 0; distance < frames; distance += 1) {
        if (images[wanted - distance]) return wanted - distance;
        if (images[wanted + distance]) return wanted + distance;
      }
      return -1;
    };
    const paint = () => {
      if (picture === null) return;
      // The frame under the place drawn, and the share of the next one, in steps of 1/32
      let frame = Math.floor(picture);
      let share = Math.round((picture - frame) * 64) / 64;
      if (share === 1) {
        frame += 1;
        share = 0;
      }
      // Both frames not in yet: the nearest one loaded, alone
      if (!images[frame] || (share && !images[frame + 1])) {
        frame = nearest(Math.round(picture));
        share = 0;
      }
      if (frame < 0 || frame + share === drawn) return;
      const image = images[frame];
      if (!canvas) {
        // Sized on the first frame in: the CSS fits it to the stage like the picture under it
        canvas = document.createElement('canvas');
        canvas.className = 'kodza-scroll-sequence__canvas';
        canvas.setAttribute('aria-hidden', 'true');
        canvas.width = image.naturalWidth;
        canvas.height = image.naturalHeight;
        context = canvas.getContext('2d');
        if (poster) poster.after(canvas);
        else stage.prepend(canvas);
        root.classList.add('is-drawn');
      }
      context.globalAlpha = 1;
      context.drawImage(image, 0, 0, canvas.width, canvas.height);
      if (share) {
        context.globalAlpha = share;
        context.drawImage(images[frame + 1], 0, 0, canvas.width, canvas.height);
        context.globalAlpha = 1;
      }
      drawn = frame + share;
    };
    const pump = () => {
      const pattern = root.dataset.src;
      while (loading.size < PARALLEL && next < order.length) {
        const frame = order[next];
        next += 1;
        const image = new Image();
        image.decoding = 'async';
        image.src = pattern.replace('{index}', String(frame + 1).padStart(pad, '0'));
        loading.add(image);
        image.decode().then(() => {
          if (signal.aborted) return;
          images[frame] = image;
          paint();
        }, () => {}).finally(() => {
          loading.delete(image);
          if (!signal.aborted) pump();
        });
      }
    };
    const load = () => {
      if (order.length) return;
      const queued = new Set();
      PASSES.forEach((step) => {
        for (let frame = 0; frame < frames; frame += step) queued.add(frame);
      });
      queued.add(frames - 1);
      order = [...queued];
      pump();
    };

    // The track: 0 as the stage reaches the top of the screen, 1 as it lets go
    const goal = () => {
      const box = root.getBoundingClientRect();
      const span = box.height - stage.getBoundingClientRect().height;
      return span > 0 ? clamp(-box.top / span, 0, 1) : 0;
    };
    const write = () => {
      root.style.setProperty('--kz-scroll-sequence-progress', current.toFixed(4));
      index = Math.round(current * (frames - 1));
      if (counter) counter.textContent = `${String(index + 1).padStart(digits, '0')} / ${total}`;
      paint();
      // The caption on is the last one whose point is passed
      let now = 0;
      at.forEach((point, i) => {
        if (current >= point - SETTLE) now = i;
      });
      ticks.forEach((tick, i) => tick.classList.toggle('is-passed', current >= at[i] - SETTLE));
      if (now === on) return;
      on = now;
      captions.forEach((caption, i) => {
        caption.classList.toggle('is-current', i === now);
        caption.classList.toggle('is-past', i < now);
      });
    };
    const tick = (time) => {
      raf = 0;
      const to = goal();
      const frame = last ? Math.min(time - last, 64) : 16.7;
      last = time;
      if (to !== target) {
        if (target !== null) way = Math.sign(to - target);
        target = to;
        moved = time;
      }
      const ease = 1 - Math.exp(-frame / smoothing);
      if (current === null || !smoothing) leading = current = to;
      else {
        leading += (to - leading) * ease;
        current += (leading - current) * ease;
      }
      if (Math.abs(to - current) < SETTLE && Math.abs(to - leading) < SETTLE) leading = current = to;
      // The picture follows the same glide, between two frames, then on to a whole one at rest. It
      // waits there while the scroll picks up the same way, so the turn never steps back
      const exact = to * (frames - 1);
      const resting = time - moved >= REST;
      if (resting) held = way < 0 ? Math.floor(exact + 0.001) : Math.ceil(exact - 0.001);
      else if (held !== null && (way < 0 ? exact <= held : exact >= held)) held = null;
      const aim = !smoothing ? Math.round(exact) : held ?? exact;
      if (picture === null || !smoothing) turning = picture = aim;
      else {
        turning += (aim - turning) * ease;
        picture += (turning - picture) * ease;
      }
      if (Math.abs(aim - picture) < 0.01 && Math.abs(aim - turning) < 0.01) turning = picture = aim;
      write();
      if (current !== to || picture !== aim || !resting) raf = requestAnimationFrame(tick);
      else last = 0;
    };
    const queue = () => {
      if (!shown || raf) return;
      raf = requestAnimationFrame(tick);
    };
    const place = () => {
      current = goal();
      target = current;
      picture = Math.round(current * (frames - 1));
      held = picture;
      leading = current;
      turning = picture;
      write();
    };

    // Placed before it first shows, so the captions do not roll in front of you on load
    place();

    // Focus landing in a caption that is not on (a link in its text, from the keyboard): the page
    // scrolls to where that caption comes in
    root.addEventListener('focusin', (event) => {
      const i = captions.findIndex((caption) => caption.contains(event.target));
      if (i < 0 || i === on) return;
      const box = root.getBoundingClientRect();
      const span = box.height - stage.getBoundingClientRect().height;
      window.scrollTo({ top: scrollY + box.top + at[i] * span, behavior: 'instant' });
      place();
    }, { signal });

    const io = new IntersectionObserver(([entry]) => {
      shown = entry.isIntersecting;
      if (!shown) return;
      load();
      place(); // back on screen after a jump (an anchor, Home): placed, not chased
    }, { rootMargin: `${AHEAD} 0px` });
    io.observe(root);
    const resize = new ResizeObserver(queue);
    resize.observe(stage);
    window.addEventListener('scroll', queue, { passive: true, signal });
    window.addEventListener('resize', queue, { signal });
    signal.addEventListener('abort', () => {
      io.disconnect();
      resize.disconnect();
      cancelAnimationFrame(raf);
      // Downloads still running stop, and the frames go with the instance
      loading.forEach((image) => image.removeAttribute('src'));
      loading.clear();
      images.fill(null);
      canvas?.remove();
    });
  }

  // Kodza lifecycle, the same in every component: `kodza:init` starts the instances inside
  // event.detail.root (the whole page by default), `kodza:destroy` stops them and puts their
  // markup back. For themes and apps that swap content without a page load. Each running root
  // keeps its markup as written under KODZA, shared by every Kodza script on the page: a Kodza
  // component inside another one is saved as written, not half-started, and stopped with it. Two
  // components on one root (a reveal on a stat card) both start, and stop together.
  const KODZA = Symbol.for('kodza');
  const RUNNING = Symbol.for(`kodza ${SELECTOR}`); // a root this component runs on, for every copy of this script
  const instances = new WeakMap();
  const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
  const attrsOf = (el) => [...el.attributes].map((a) => [a.name, a.value]);
  const put = (el, saved) => {
    [...el.attributes].forEach((a) => el.removeAttribute(a.name));
    saved.attrs.forEach(([name, value]) => el.setAttribute(name, value));
    el.innerHTML = saved.html;
  };
  // The markup inside a root as written: Kodza components already running in it give back their own
  const written = (root) => {
    const all = [...root.querySelectorAll('*')];
    if (!all.some((el) => el[KODZA])) return root.innerHTML;
    const copy = root.cloneNode(true);
    const twins = copy.querySelectorAll('*');
    let last = null;
    all.forEach((el, i) => {
      if (!el[KODZA] || last?.contains(el)) return;
      last = el;
      put(twins[i], el[KODZA]);
    });
    return copy.innerHTML;
  };
  const init = (scope) => find(scope).forEach((root) => {
    // Already running, maybe from another copy of this script. Marked is-ready with no Kodza component
    // running on it, a root is a copy of a started one (a cloned slide): it is left as it is
    if (root[RUNNING] || (root.classList.contains('is-ready') && !root[KODZA])) return;
    // Rendered by React (data-kodza-manual): React starts it, with an init aimed at that markup once
    // it has hydrated it. Any earlier start would change markup React has not taken over yet
    const owner = root.closest('[data-kodza-manual]');
    if (owner && !(scope && owner.contains(scope))) return;
    const controller = new AbortController();
    // Another Kodza component already running on this root: its markup as written is kept, and the
    // two stop together
    const before = root[KODZA];
    const saved = { html: before ? before.html : written(root), attrs: before ? before.attrs : attrsOf(root), stop: () => destroy(root) };
    if (before) before.above = saved;
    instances.set(root, { controller, saved, before });
    root[KODZA] = saved;
    root[RUNNING] = true;
    mount(root, controller.signal);
    root.classList.add('is-ready');
  });
  const destroy = (scope) => find(scope).forEach((root) => {
    const instance = instances.get(root);
    if (!instance) return;
    instances.delete(root);
    instance.saved.above?.stop(); // a Kodza component started after it on the same root stops first
    // The Kodza components running inside it stop first: once its markup is put back, their own
    // script could not find them any more
    root.querySelectorAll('*').forEach((el) => el[KODZA]?.stop());
    instance.controller.abort();
    delete root[RUNNING];
    // Started on top of another one: that one stops next, and puts the markup back
    if (instance.before) {
      delete instance.before.above;
      root[KODZA] = instance.before;
      return instance.before.stop();
    }
    delete root[KODZA];
    put(root, instance.saved);
  });
  document.addEventListener('kodza:init', (event) => init(event.detail?.root));
  document.addEventListener('kodza:destroy', (event) => destroy(event.detail?.root));
  init();
  // Loaded in <head>, the script runs before the markup exists: once more when it is parsed
  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => init(), { once: true });
})();
```

Free to use, from Kodza (https://kodza.dev).
