Skip to content
animorio
IT
Back to the library

Metro map scroll

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

Scroll inside the preview

A scroll animation for a city guide: the metro map card of Halvern, a made-up city, in the Wayline app. As you scroll, the four coloured lines draw one after the other at 45 degrees as on real diagrams, led by a white head; behind it the station ticks pop in and the interchanges open as white rings, and the line's chip fills in the header. When a line is done, its station of the moment lights up with its name in bold and a ring of its colour closing around it, and a small real photo of the neighbourhood rises from the station on a thin stem: the stone bridge, the street market, the street of shops, the boats at the quay. Below, the card's footer rolls to the station with its line and the minutes from the centre.

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>
<!--
  "Metro map scroll" 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>Wayline, the Halvern metro map</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>
  <!-- the metro map card of a made-up city guide, Wayline, for a made-up city, Halvern. On scroll the four lines draw
       one after the other at 45 degrees, their stations ticking in behind the drawing head; when a line is done its
       station of the moment lights up with its name and a small photo of the neighbourhood rises from it -->
  <section class="corsa" data-corsa>
    <div class="palco">
      <article class="card" data-card>
        <header class="testa">
          <span class="marchio">
            <svg viewBox="0 0 20 20" aria-hidden="true">
              <rect x="1" y="1" width="18" height="18" rx="5.5"/>
              <path d="M5 13.5h3.2l3.6-3.6H15"/>
              <circle cx="8.2" cy="13.5" r="1.25"/>
            </svg>
            <span class="marchio-nome">Wayline</span>
            <span class="marchio-citta">Halvern</span>
          </span>
          <ul class="linee" data-linee aria-label="Lines"></ul>
        </header>

        <div class="mappa" data-mappa>
          <svg class="rete" data-rete viewBox="0 0 400 300" preserveAspectRatio="xMidYMid meet" aria-label="Halvern metro map">
            <defs>
              <pattern id="isolati" width="16" height="16" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
                <path d="M0 0h16M0 0v16" fill="none" stroke="#1e1c18" stroke-opacity="0.045" stroke-width="0.4"/>
              </pattern>
            </defs>
            <g class="fondo" data-fondo>
              <rect class="isolati" x="-40" y="-40" width="480" height="380" fill="url(#isolati)"/>
              <path class="mare" d="M412 52 L392 72 L392 312 L412 312 Z"/>
              <rect class="parco" x="104" y="80" width="40" height="40" rx="7"/>
              <path class="fiume" d="M70 312 L70 245 L100 215 L100 190 L150 140 L150 60 L200 10 L200 -12"/>
              <path class="fiume-luce" d="M70 312 L70 245 L100 215 L100 190 L150 140 L150 60 L200 10 L200 -12"/>
              <text class="nome-acqua" x="160" y="44" transform="rotate(-45 160 44)">River Aven</text>
              <text class="nome-parco" x="124" y="103">Aven Park</text>
            </g>
            <g data-casse></g>
            <g data-tracce></g>
            <g data-fermate></g>
            <g data-teste></g>
          </svg>
          <div class="cartoline" data-cartoline></div>
          <p class="invito" data-invito>
            <span>Scroll to ride the lines</span>
            <svg viewBox="0 0 12 12" aria-hidden="true"><path d="M6 2v8M2.8 6.8 6 10l3.2-3.2"/></svg>
          </p>
          <span class="grana" aria-hidden="true"></span>
        </div>

        <footer class="piede" data-piede></footer>
      </article>
      <p class="nota">Halvern, its metro and Wayline are made up.</p>
    </div>
  </section>

  <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.

24 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 “Metro map scroll” 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 warm grey page sits a light paper card with the header of the Wayline app (the mark, the city, Halvern) and on the right the four chips of the lines: Harbour, Riverside, Market and Parkway, each with an empty bar of its colour. Below, set into the card, the map: paper with a faint 45 degree pattern of blocks, the river Aven crossing the city in bends with a thread of light drifting slowly along it, the park and the strip of sea. At the bottom the pill ‘Scroll to ride the lines’. As you scroll, the red line draws from west to east with a white head with a red rim at its tip; behind it the station ticks pop in with a small bounce, the interchanges open as white rings with a dark rim, the names light up, and the chip's bar fills in step. A paper casing runs under every line, so where two lines cross the top one stands off the one below. When the line is done, its station of the moment lights up: a white ring opens with a bounce, a thin ring in the line's colour closes around it, the name turns black and bold. From the station a stem rises and on it a card with a real photo of the neighbourhood, which arrives a little small and tilted and settles with a bounce while the photo inside slowly widens; the name sits on the photo with the colour bar. The card's footer rolls to the station: the coloured badge with the train, the big name, the line about the neighbourhood and the minutes from Central. When the next line starts, the card sinks back into its station and the ring opens again. Blue leads to the street market, yellow to the street of shops, green to the boats in the harbour. Pointing at a chip keeps its line full and fades the others. Scrolling back undoes it all.

How it works

Lines as lists of corners

Each line is a list of points on a 400 by 300 map, and between two points it only goes across, up and down or at 45 degrees, as on real metro diagrams. The script turns it into a path, measures its length by adding up the segments and, for every stop, works out how far along the line it sits by projecting it onto the right segment.

The stroke that moves forward

Every line has a value p from 0 to 1: stroke-dasharray is as long as the line and the stroke-dashoffset, changed as an attribute, is the length times 1 − p. The white head is placed at that fraction of the line, and every stop gets the class su when p passes it: the tick and the interchange ring open with a springy CSS transition, so scrolling back closes them on their own.

One scrubbed timeline

A single paused timeline, four steps long plus a pause: in each step the line draws in the first half, then the station ring, the photo card and the footer. ScrollTrigger drives it from top top to bottom bottom of a section five screens tall, with Lenis for smooth scrolling; its onUpdate redraws the lines and lights the name of the station of the moment.

The photo card measured in pixels

The station's place on the page comes from the SVG's matrix (getScreenCTM): the card sits there, above the station if there is room and below if not, moved sideways just enough to stay inside the map. It is measured again on every resize, because the demo's window changes size while you look at it; GSAP only moves the sheet inside, with its origin on the station.

Values to change

NameFileDefaultWhat it changes
DRAWscript.js0.5How much of each step drawing the line takes; the rest is the station and a pause.
STROKEscript.js4.6The width of the lines, in map units.
CARDscript.js0.27The width of the photo card, as a share of the map.
RISEscript.js14How many pixels the photo card rises from the station.
RIDEscript.js1How much scroll the section takes: 2 is twice as long.
SMOOTHscript.js1.1Seconds the smooth scroll takes to catch up with the wheel.
WATERscript.js11 lets the thread of light drift along the river, 0 keeps it still.

Try them in the Playground

When to use it

For a city guide, the site of a tourist office, a hotel or an event that wants to show how to get there: when a map should tell, one line at a time, the places to see and how far away they are.

On phones

The same animation with adapted sizes: the card takes almost the whole screen, the line chips keep only their coloured bar, the whole map shrinks to fit and the photo card has a minimum width, moved sideways so it never leaves the map. You scroll with your finger.

With reduced motion

No movement: every line fades in whole, the ticks and rings are already in place, the photo card and the footer change with a fade; no smooth scroll and the river stays still.

Pitfalls

  • The line's length is worked out by adding up its segments instead of asking getTotalLength: so the fraction of every stop and that of the drawn stroke come from the same numbers, and the tick pops in exactly when the head passes over it.
  • The stroke-dashoffset is changed as an attribute: as a CSS property some browsers round it and halfway the line jumps.
  • The stops' classes are decided by the drawing function, looking at p, not by calls in the timeline: when scrubbing backwards calls fire the wrong way or not at all, while a computed class is always right.
  • The photo card must not be moved with left and top by GSAP: the wrapper sits on the station with left and top in pixels worked out again on resize, and GSAP only moves the sheet inside with transforms.
  • clip-path on a card with shadows cuts the shadow too: the card rises with opacity, scale and a degree of rotation, and the photo widens inside its window with overflow: hidden.

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 12 KB; the libraries: GSAP + ScrollTrigger 45 KB, Lenis 5.3 KB.

Testing

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