Skip to content
animorio
IT
Back to the library

Chapter ruler

Scroll, HoverGSAP, CSS onlyMediumCompressed weight: Demo 10 KBGSAP + ScrollTrigger 45 KBLenis 5.3 KBFreeDownload the zip

Scroll inside the preview

The scrolling page of a made-up course, the Keelson Analyst Track, five chapters from the first brief to a job offer. Fixed at the top there is a short 300 pixel ruler: a small tick every 10vh of scroll, a tall named tick at every chapter, the track sliding under a still needle and a lens that lifts the nearby ticks from 9 to 18 pixels. Under the mouse the ruler turns into five buttons that take you to a chapter. On the right a glass pill keeps the points: +100 the first time you reach each chapter, the number counting for 2 seconds and the edge lighting up gold.

Rebuilt from scratch studying why.zero.university by Sindhur Dutta, Zero: the idea is theirs; code, copy and images are ours. Read how it’s made

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Chapter ruler" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Keelson Analyst Track</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist@5.3.0/index.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the scrolling page of a made-up course, the Keelson Analyst Track: five chapters from a real brief to a job offer.
       Fixed at the top, a short ruler tells where you are: one small tick every 10vh of scroll, a tall tick with its
       name at every chapter, the track sliding under a still needle and a lens that lifts the ticks near it. Hover the
       ruler and it turns into five buttons that take you to a chapter. On the right a glass pill keeps your points:
       +100 the first time you reach each chapter. -->
  <div class="hud" data-hud>
    <nav class="ruler" data-ruler aria-label="Chapters">
      <div class="ruler__track" data-track aria-hidden="true"></div>
      <div class="ruler__needle" data-needle aria-hidden="true"></div>
      <div class="ruler__nav" data-nav></div>
    </nav>

    <div class="xp" data-xp aria-live="polite">
      <svg class="xp__icon" viewBox="0 0 16 16" aria-hidden="true">
        <path class="xp__hex" d="M8 1.6 13.5 4.8v6.4L8 14.4 2.5 11.2V4.8z"/>
        <path class="xp__core" d="M8 5.2 10.4 6.6v2.8L8 10.8 5.6 9.4V6.6z"/>
      </svg>
      <span class="xp__value" data-xp-value>0</span>
      <span class="xp__label">XP</span>
      <span class="xp__gain" data-xp-gain aria-hidden="true">+100</span>
    </div>
  </div>

  <main class="course">
    <section class="chapter" data-chapter data-label="Brief">
      <div class="chapter__inner">
        <p class="chapter__kicker"><b>Keelson Analyst Track</b><span class="soft">Brief, weeks 1 to 2</span></p>
        <h2 class="chapter__title" data-title>Start with a real brief.</h2>
        <p class="chapter__line">A grocery chain wants to know why baskets got smaller. You get the same email their analyst got.</p>
        <div class="meta">
          <div class="meta__cell"><span>Lessons</span><b>6</b></div>
          <div class="meta__cell"><span>Time</span><b>4 h 20</b></div>
          <div class="reward" data-reward><span class="reward__idle">+100 XP</span><span class="reward__done"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M2.4 6.3 4.9 8.7 9.6 3.6" pathLength="1"/></svg>Earned</span></div>
        </div>
      </div>
    </section>

    <section class="chapter" data-chapter data-label="Data">
      <div class="chapter__inner">
        <p class="chapter__kicker"><b>Data</b><span class="soft">Weeks 3 to 5</span></p>
        <h2 class="chapter__title" data-title>Clean what they give you.</h2>
        <p class="chapter__line">Forty thousand receipts, three date formats and one missing week. Nobody tidies it for you.</p>
        <div class="meta">
          <div class="meta__cell"><span>Lessons</span><b>8</b></div>
          <div class="meta__cell"><span>Time</span><b>6 h 10</b></div>
          <div class="reward" data-reward><span class="reward__idle">+100 XP</span><span class="reward__done"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M2.4 6.3 4.9 8.7 9.6 3.6" pathLength="1"/></svg>Earned</span></div>
        </div>
      </div>
    </section>

    <section class="chapter" data-chapter data-label="Model">
      <div class="chapter__inner">
        <p class="chapter__kicker"><b>Model</b><span class="soft">Weeks 6 to 8</span></p>
        <h2 class="chapter__title" data-title>Find the reason, not a chart.</h2>
        <p class="chapter__line">Build the basket model in a notebook a reviewer can run again from the first cell.</p>
        <div class="meta">
          <div class="meta__cell"><span>Lessons</span><b>7</b></div>
          <div class="meta__cell"><span>Time</span><b>5 h 40</b></div>
          <div class="reward" data-reward><span class="reward__idle">+100 XP</span><span class="reward__done"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M2.4 6.3 4.9 8.7 9.6 3.6" pathLength="1"/></svg>Earned</span></div>
        </div>
      </div>
    </section>

    <section class="chapter" data-chapter data-label="Pitch">
      <div class="chapter__inner">
        <p class="chapter__kicker"><b>Pitch</b><span class="soft">Weeks 9 to 10</span></p>
        <h2 class="chapter__title" data-title>Say it in four slides.</h2>
        <p class="chapter__line">Present to a hiring manager who has already read a hundred decks this year.</p>
        <div class="meta">
          <div class="meta__cell"><span>Lessons</span><b>5</b></div>
          <div class="meta__cell"><span>Time</span><b>3 h 30</b></div>
          <div class="reward" data-reward><span class="reward__idle">+100 XP</span><span class="reward__done"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M2.4 6.3 4.9 8.7 9.6 3.6" pathLength="1"/></svg>Earned</span></div>
        </div>
      </div>
    </section>

    <section class="chapter" data-chapter data-label="Offer">
      <div class="chapter__inner">
        <p class="chapter__kicker"><b>Offer</b><span class="soft">Week 11</span></p>
        <h2 class="chapter__title" data-title>Walk in with proof.</h2>
        <p class="chapter__line">Your project, reviewed and signed, goes to the partner teams that are hiring now.</p>
        <div class="meta">
          <div class="meta__cell"><span>Partner teams</span><b>38</b></div>
          <div class="meta__cell"><span>To an offer</span><b>9 wks</b></div>
          <div class="reward" data-reward><span class="reward__idle">+100 XP</span><span class="reward__done"><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M2.4 6.3 4.9 8.7 9.6 3.6" pathLength="1"/></svg>Earned</span></div>
        </div>
      </div>
    </section>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/ScrollTrigger.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/lenis@1.3.26/dist/lenis.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

72 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Chapter ruler” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On a near black page with a faint green light under the bar and a very fine grain, each chapter of the course fills the window: at the top the chapter name and its weeks in mono letters, a big title («Start with a real brief.», «Clean what they give you.», «Find the reason, not a chart.», «Say it in four slides.», «Walk in with proof.»), a grey line and under it a thin rule with two figures, lessons and hours, and the «+100 XP» chip. At the top in the middle sits the ruler: on arrival the ticks rise from the needle outwards with a small bounce and the needle drops into place. As you scroll the track slides under the needle; the ticks within three steps grow up to twice their height as if under a lens and shrink back as they move away; every chapter has its tall named tick, which turns gold and white when you are on it, and the needle gives a little kick each time it crosses one. On the first visit of each chapter the pill on the right takes a one pixel hit, its edge lights up gold and fades in 1.8 seconds, the hexagon turns, a «+100» rises below it and the number counts up to the new total; in the chapter the «+100 XP» chip slides away and «Earned» arrives with its check drawing itself. With the mouse on the ruler the ticks vanish and five mono buttons appear with a line under each that stretches; the one of the chapter you are in has the longest, thickest line, and clicking another one turns a small ring in place of its name while the page scrolls there. Left alone, the page scrolls down and back up.

How it works

Ticks from the real heights

The ruler is built from the real heights of the chapters: a tall tick for each chapter at its position (offsetTop over the maximum scroll) and between one and the next Math.round(height in vh / 10) - 1 small ticks, one every 10vh. The track is (number of ticks - 1) times 12 pixels wide and every tick sits at progress times width, minus half a step. On resize it is rebuilt.

The track under the still needle

On every frame of the GSAP ticker the scroll progress moves the track by centre minus progress times width, with a translate3d: at progress 0 the first tick is under the needle, at 1 the last one. The needle, 2 by 18 pixels, never moves. On the sides a mask from transparent to black at 8% and 92% makes the ticks fade at the edges.

The lens

The lens reaches three times the average gap between two small ticks. For each tick inside it the distance becomes n between 0 and 1, the smoothstep n times n times (3 - 2n) gives the height from 18 down to 9 pixels, rounded to a tenth: the style is written only when the height really changes, and far ticks go back to rest only once.

The chapter buttons

With the mouse over it the ruler takes the is-nav class: track and needle go to opacity 0 in 0.25 seconds, the mask comes off and five buttons appear 26 pixels apart, with a line under each from 28 to 40 pixels; the active one is 2 tall. A click asks Lenis to scroll to the chapter with a cubic ease while a 12 pixel ring turns in place of the name. On a phone a tap opens and closes the buttons.

Points that count

A Set remembers the chapters already seen: on a first visit the total becomes chapters seen times 100 and a 2 second power2.out tween writes the number into a single text node, leaving the rest of the pill alone. The is-ripple class, removed and added again after reading offsetWidth, restarts two 1.8 second keyframes from zero: the gold ring with its halo and the warming fill.

Smooth scroll and entrances

Lenis 1.3.26 does the smooth scroll and calls ScrollTrigger.update; its raf runs in the GSAP ticker. Each chapter has a ScrollTrigger that, when it reaches 72% of the window, lifts the words of the title out of their slot, one every 0.07 seconds, then the line and the figures.

Values to change

NameFileDefaultWhat it changes
RULER_WIDTHscript.js300Width of the ruler in pixels (the site uses 300).
TICK_EVERYscript.js10One small tick every this many vh of scroll (the site uses 10).
TICK_STEPscript.js12Pixels between two ticks on the ruler (the site uses 12).
LENS_STEPSscript.js3How many ticks on each side the lens lifts (the site uses 3).
LENS_HEIGHTscript.js18Height in pixels of the tick right under the needle; at rest they are 9.
POINTSscript.js100Points for reaching a chapter the first time (the site gives 100).
COUNT_TIMEscript.js2Seconds the number takes to count up to the new total (the site uses 2).
GLOW_TIMEscript.js1.8Seconds the edge of the pill stays lit (the site uses 1.8).
SMOOTHscript.js1.1Seconds of the Lenis smooth scroll; 0 for the browser’s plain scroll.

Try them in the Playground

When to use it

For a long page split into chapters or stages: an online course, a training path, a scrolling story, a case study, an annual report or the onboarding of an app. When you want to tell people where they are without a progress bar, and reward those who keep going with a small points game.

On phones

The same animations with adapted sizes: the ruler stays, narrower (up to 300 pixels, leaving room for the pill) and moved to the left, the pill on the right on the same row, the chapter buttons closer together; the chapters are sized on the height too. Without a mouse a tap on the ruler opens the buttons and a tap outside closes them.

With reduced motion

No lens: the ticks all stay short and the track only follows the scroll. No smooth scroll and no ride to the chapters: the button jumps at once. The points change without counting, the gold edge only fades, titles and chips fade in.

Pitfalls

  • The lens has to be rounded to a tenth of a pixel and written only when it changes: rewriting 40 transforms every frame even while still keeps the style engine busy for nothing. The Why Zero site does the same.
  • The number goes into a text node (nodeValue), not textContent on the pill: textContent would wipe the icon and the label and make the children be measured again every frame.
  • To restart a CSS animation already running, the class is removed, offsetWidth is read and the class is added back: without the read the browser merges the two changes and the ring does not light again.
  • The ruler is built once the chapters have their height and rebuilt on resize: the ticks depend on the maximum scroll, which on a phone changes when the browser bar hides.
  • The last chapter never reaches the middle of the window when the page is at the bottom: at the end of the scroll the active chapter is forced to the last one, otherwise its points never arrive.
  • A phone has no hover: without the tap that opens the buttons the navigation would stay hidden.

Libraries

GSAP 3.15.0, ScrollTrigger 3.15.0, Lenis 1.3.26, Geist (font variabile) 5.3.0, Geist Mono (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 10 KB; the libraries: GSAP + ScrollTrigger 45 KB, Lenis 5.3 KB.

Testing

Tested on 11 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations