Skip to content
animorio
IT
Back to the library

Scroll vernier

Scroll, SVGGSAPMediumCompressed weight: Demo 6.4 KBGSAP + ScrollTrigger 45 KBLenis 5.3 KBFreeDownload the zip

Scroll inside the preview

A minimal scroll animation: the vernier of a caliper, the fine scale that reads tenths of a millimetre. Scrolling slides the main scale over the still vernier, and where two ticks meet they reach for each other and take the accent, so the meeting point runs along the vernier like a wave. Above it, the reading to a tenth; when the scroll stops the scale settles on the nearest tenth, one pixel past and back.

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>
<!--
  "Scroll vernier" 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>The vernier that reads the scroll</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- a vernier scale, the fine reading of a caliper. Scrolling slides the main scale along the fixed vernier; where a
       vernier tick meets a main tick the two reach for each other and take the accent, so the meeting point runs along
       the vernier like a wave. The reading above shows it to a tenth. When the scroll stops the scale settles on the
       nearest tenth, one pixel past and back, and the pair that meets gives a small knock. The scale can be pulled
       sideways with the pointer: let go, it springs back to where the scroll wants it -->
  <main class="pagina">
    <section class="corsa" data-corsa aria-label="Vernier scale">
      <div class="palco">
        <div class="pezzo" data-pezzo>
          <p class="lettura" aria-live="off">
            <span class="lettura__intero" data-intero>0</span><span class="lettura__punto">.</span><span class="lettura__decimo"><span data-decimo>0</span></span><span class="lettura__unita">mm</span>
          </p>
          <svg class="scala" data-scala aria-hidden="true">
            <g data-principale></g>
            <line class="scala__bordo" data-bordo-p></line>
            <line class="scala__bordo scala__bordo--nonio" data-bordo-n></line>
            <g data-nonio></g>
          </svg>
          <p class="nota" data-nota>Vernier, 0.1 mm</p>
        </div>
        <p class="scendi" data-scendi>Scroll</p>
      </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.

17 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 “Scroll vernier” 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 empty warm white a thin rule draws itself from the middle out and ticks rise on both sides of it, the middle ones first, with a small bounce: above the rule the main scale of a caliper, one tick per millimetre, longer every five and numbered every ten; below it the vernier, eleven ticks a little closer together, from 0 to 10. At the top the reading, large: 0.0 mm, with the tenth in orange. Scrolling the page, which stays pinned, slides the main scale to the left over the vernier. Where a vernier tick sits right under a tick of the scale the two reach for each other and turn orange, their neighbours only a little; while the scale moves the meeting point runs along the vernier like a wave, left to right with every millimetre, and the lit tick tells the tenth. The reading climbs with the scale: the whole millimetres change and the orange tenth rolls in from above or below. Every pair that meets lights up and fades on its own spring. When the scroll stops the scale settles on the nearest tenth, one pixel past and back, and the aligned pair gives a small knock, stretching and coming back. The scale can be pulled sideways with the pointer or a finger, harder the further it goes: let go, it springs back to where the scroll wants it. At the bottom of the page the reading is 34.7 mm; scrolling back undoes it all.

How it works

How a vernier reads

The vernier has ten divisions, each nine tenths of a millimetre long. With the scale moved by v millimetres, vernier tick j falls at v + 0.9·j on the scale: it is aligned when that number is whole, and the j that manages it is the tenth.

A bell for the meeting

For every tick the script measures how many pixels separate it from the nearest tick of the other scale, and its glow is a Gaussian bell of that distance (0.07 millimetres wide). The neighbour, a tenth away, stays almost dark; every tick chases its glow on a small spring.

The scale on a spring

ScrollTrigger only gives the progress. The scale chases the wanted reading on a spring (stiffness 140, damping below critical), integrated in steps of 1/120 of a second in the GSAP ticker: that is where the pixel past comes from.

Settling on the tenth

If the progress has not changed for 0.16 seconds, the wanted reading is rounded to the tenth and the spring takes the scale there. Once it is still, a knock value goes from 1 to 0 and stretches the aligned pair for a moment.

Pulling it with a finger

While dragging, the movement in pixels over the width of a millimetre is added to the wanted reading, with a resistance that grows; on release it goes back to zero and the same spring brings the scale back to where the scroll wants it. touch-action: pan-y keeps the page scrolling vertically.

Values to change

NameFileDefaultWhat it changes
LENGTHscript.js34.7The reading at the end of the scroll, in millimetres.
DIVISIONSscript.js10Divisions of the vernier: 10 reads tenths, 20 reads twentieths.
REACHscript.js1How far the meeting ticks reach for each other (0 = they only change colour).
STIFFNESSscript.js140The spring that carries the scale: higher is quicker.
BOUNCEscript.js0.3How far the scale goes past before it settles (0 = not at all).
SNAPscript.jstrueWhen the scroll stops, the scale settles on the nearest division.
SMOOTHscript.js1.1Seconds of the smooth scroll; 0 for the browser’s own.

Try them in the Playground

When to use it

For the page of a precision product, a machine shop or an engineering studio, to show a part’s tolerances or the care of a tool brand; and as a quiet scroll indicator in a technical article.

On phones

The same animation with adapted sizes: the millimetre is as wide as the box allows, in width and height, and the scale can be pulled sideways with a finger while the page scrolls vertically.

With reduced motion

No movement: the scale is already at 34.7 mm, with the aligned pair in orange, and it appears in a fade.

Pitfalls

  • Ticks go on the half pixel (rounded plus 0.5): a 1-wide line on a whole pixel gets spread over two and the close ticks look blurry.
  • The snap to the tenth only comes when the scroll has stopped: rounding all the time would make the scale jump instead of glide.

Libraries

GSAP 3.15.0, ScrollTrigger 3.15.0, Lenis 1.3.26, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 1 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