Skip to content
animorio
IT
Back to the library

Train journey pass

ScrollGSAP, CSS onlyMediumCompressed weight: Demo 9.8 KBGSAP + ScrollTrigger 45 KBLenis 5.3 KBFreeDownload the zip

Scroll inside the preview

The post of a made-up personal travel blog, Slow Platform, in the premium style of the interface pieces: four days by train from Zurich to Milano. The stage holds still and the scroll is the journey: through the window the landscape (a real photo) slides by, a small red train runs along the line printed on the pass, and at every station the conductor punches it: the paper gives under the punch and springs back, a red ring draws itself, the hole bites through with a pixel of overshoot and the little disc of paper drops away tumbling. Meanwhile the diary turns to the next day and the kilometres count up.

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>
<!--
  "Train journey pass" 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>Slow Platform, four trains to Milano</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/full.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- a post of a made-up personal travel blog, Slow Platform: four days by train from Zurich to Milano. The stage
       sticks while you scroll and the scroll is the journey: the view through the window slides by, a small train
       runs along the line of the rail pass, and at every station the conductor punches the pass (the paper gives,
       a hole bites through, the little disc of paper drops away) while the diary turns to the next day. -->
  <main>
    <section class="trip" data-trip>
      <div class="stage" data-stage>
        <div class="grain" aria-hidden="true"></div>

        <article class="post" data-post>
          <span class="post__edge" aria-hidden="true"></span>

          <figure class="window" data-window>
            <div class="window__glass">
              <img class="window__view" data-view src="finestrino.webp" alt="Green meadows and a rocky peak seen from the train" width="960" height="640">
              <span class="window__shine" data-shine aria-hidden="true"></span>
            </div>
            <figcaption class="window__cap">
              <svg viewBox="0 0 16 16" aria-hidden="true"><rect x="3" y="2.2" width="10" height="11.6" rx="2.6"/><path d="M3 9h10"/></svg>
              <span>From the window seat</span>
            </figcaption>
          </figure>

          <div class="body">
            <header class="blog">
              <span class="blog__mark" aria-hidden="true">
                <svg viewBox="0 0 20 20"><path d="M5 2.5 3 17.5M15 2.5l2 15"/><path d="M4.6 6h10.8M4.1 10h11.8M3.6 14h12.8"/></svg>
              </span>
              <span class="blog__name">Slow Platform</span>
              <span class="blog__meta">Rail notes &middot; 6 min read</span>
            </header>

            <h1 class="title">Four trains to Milano</h1>

            <div class="entry" data-entry aria-live="polite">
              <p class="entry__kick" data-kick>Mon 9 Nov &middot; Z&uuml;rich</p>
              <h2 class="entry__head" data-head>Packing light for the slow way down</h2>
              <p class="entry__text" data-text>One bag, one pass, four trains. The plan is to see the Alps at the speed of a window seat.</p>
            </div>

            <div class="pass" data-pass>
              <div class="pass__paper" data-paper>
                <span class="pass__grain" aria-hidden="true"></span>
                <div class="pass__top">
                  <span class="pass__brand">Alpine Rail Pass</span>
                  <span class="pass__valid">Valid 9&ndash;13 Nov &middot; 2nd class</span>
                </div>

                <div class="line" data-line aria-hidden="true">
                  <span class="line__base"></span>
                  <span class="line__fill" data-fill></span>
                  <span class="line__tick" style="--at:0"></span>
                  <span class="line__tick" style="--at:.25"></span>
                  <span class="line__tick" style="--at:.5"></span>
                  <span class="line__tick" style="--at:.75"></span>
                  <span class="line__tick" style="--at:1"></span>
                  <span class="line__train" data-train><i></i></span>
                </div>

                <ol class="legs">
                  <li class="leg" data-leg>
                    <span class="leg__day">Tue 10</span>
                    <span class="leg__route">ZUR<svg viewBox="0 0 12 8" aria-hidden="true"><path d="M1 4h9M7.4 1.4 10 4 7.4 6.6"/></svg>CHU</span>
                    <span class="leg__km">117 km</span>
                    <span class="punch" data-punch aria-hidden="true">
                      <svg class="punch__ring" viewBox="0 0 20 20"><circle data-ring cx="10" cy="10" r="8.2" pathLength="1"/></svg>
                      <span class="punch__hole" data-hole></span>
                    </span>
                  </li>
                  <li class="leg" data-leg>
                    <span class="leg__day">Wed 11</span>
                    <span class="leg__route">CHU<svg viewBox="0 0 12 8" aria-hidden="true"><path d="M1 4h9M7.4 1.4 10 4 7.4 6.6"/></svg>SMZ</span>
                    <span class="leg__km">89 km</span>
                    <span class="punch" data-punch aria-hidden="true">
                      <svg class="punch__ring" viewBox="0 0 20 20"><circle data-ring cx="10" cy="10" r="8.2" pathLength="1"/></svg>
                      <span class="punch__hole" data-hole></span>
                    </span>
                  </li>
                  <li class="leg" data-leg>
                    <span class="leg__day">Thu 12</span>
                    <span class="leg__route">SMZ<svg viewBox="0 0 12 8" aria-hidden="true"><path d="M1 4h9M7.4 1.4 10 4 7.4 6.6"/></svg>TIR</span>
                    <span class="leg__km">61 km</span>
                    <span class="punch" data-punch aria-hidden="true">
                      <svg class="punch__ring" viewBox="0 0 20 20"><circle data-ring cx="10" cy="10" r="8.2" pathLength="1"/></svg>
                      <span class="punch__hole" data-hole></span>
                    </span>
                  </li>
                  <li class="leg" data-leg>
                    <span class="leg__day">Fri 13</span>
                    <span class="leg__route">TIR<svg viewBox="0 0 12 8" aria-hidden="true"><path d="M1 4h9M7.4 1.4 10 4 7.4 6.6"/></svg>MIL</span>
                    <span class="leg__km">150 km</span>
                    <span class="punch" data-punch aria-hidden="true">
                      <svg class="punch__ring" viewBox="0 0 20 20"><circle data-ring cx="10" cy="10" r="8.2" pathLength="1"/></svg>
                      <span class="punch__hole" data-hole></span>
                    </span>
                  </li>
                </ol>
              </div>
            </div>

            <footer class="tally">
              <span class="tally__item"><small>Travelled</small><b><span data-km>0</span> km</b></span>
              <span class="tally__item"><small>On board</small><b data-time>0h 00m</b></span>
              <span class="tally__item tally__item--end"><small>Now at</small><b data-at>Z&uuml;rich</b></span>
            </footer>
          </div>
        </article>
      </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.

45 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 “Train journey pass” 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 white grainy ground sits the white card of a post on Slow Platform, a made-up personal travel blog. On the left (on the phone on top, as a strip) the train window: a pale frame with round corners, inside it a real photo of green meadows and a rocky mountain with a reflection on the glass and an inner shadow, and the frosted From the window seat pill. On the right the blog mark, the title Four trains to Milano in Fraunces, the diary of the day (the date and the station in red, a heading and two lines) and below it the pass: the ivory Alpine Rail Pass, with its grain, two notches and dashed perforation, the line of the journey with the station ticks and a little red train with windows, and the four legs (ZUR CHU, CHU SMZ, SMZ TIR, TIR MIL) with their day and kilometres. At the bottom the tally: kilometres travelled, hours on board, where you are now. Scrolling down, the stage holds still: the landscape slides through the window, the line fills with red behind the train that rocks a hair on its rails, and when it reaches a station the conductor punches that leg: the pass gives a pixel and a half, tipping toward the blow, and springs back, a red ring draws around, the hole bites through past its size and settles, and the little disc of paper drops away tumbling and fades. The leg takes ink, the diary turns to the next day with its lines rising one after the other, the kilometres count up to the new total and the station rolls. Scrolling back the holes close again. Tapping a leg rides the page to that station.

How it works

The scroll is the journey

The section is four screens tall and the stage inside is sticky and 100vh tall (100lvh on Safari). A single scrubbed ScrollTrigger drives a paused timeline that takes a number from 0 to 1: from it come the red line and the train (two CSS variables in percent, no pixels to work out again), the landscape in the window (xPercent of a photo wider than the glass) and the stations, which fire when the number passes the ticks at a quarter, half, three quarters and the end.

The punch in four beats

When a station fires: the SVG ring with pathLength="1" goes from strokeDashoffset 1 to 0; the hole (a circle the colour of the card with an inner shadow) goes to scale 1.14 in 0.11 s and back to 1 with back.out; the pass drops 1.6 px turning a fifth of a degree toward the blow and comes back with elastic.out. The disc of paper is born over the hole but outside the paper, on the wrapper, because the paper has a mask (the notches) that would clip it: it falls, drifts, squashes in scaleY back and forth as if it were tumbling and fades.

The pass with its notches

The two notches are two transparent half circles in two radial-gradients of a mask, each over one half of the pass, at the height of the perforation. The mask clips the shadow too: that is why the shadow is a drop-shadow on the wrapper, which follows the shape with its notches.

Values to change

NameFileDefaultWhat it changes
RIDEscript.js1How much scroll the whole journey takes: 2 is twice as long.
PRESSscript.js1.6How many pixels the pass gives under the punch before it springs back.
BITEscript.js1.14How far the hole passes its size before it settles (1 for none).
DROPscript.js34How many pixels the disc of paper falls.
PANscript.js1How far the landscape slides in the window: 0 it stays still.
RINGscript.js11: a red ring draws around every hole; 0: just the hole.
--accentstyle.css#c63d2fThe rail red: the line, the train, the ring and the diary date.
--ticketstyle.css#f5eedfThe ivory of the pass paper.
--pagestyle.css#ece6dbThe warm white of the ground.

Try them in the Playground

When to use it

For the story of a trip on a personal blog, for the page of a rail itinerary of an agency or a tour operator, or for the story of a journey in stages: whoever scrolls follows the trip day by day and watches the pass fill with holes, the proof that the journey was made.

On phones

The same animation with adapted measures: the window becomes a strip on top, sized in vh, and the card, the diary and the pass are sized on width and height together so everything fits the box; the scrolling finger makes the journey and a tap on a leg rides to that station.

With reduced motion

No movement: the landscape stays still, the train and the line jump to the station, the holes fade in with no blow and no disc, the ring is already drawn and the diary changes with a fade.

Pitfalls

  • The mask that cuts the notches of the pass clips everything that leaves the paper, shadow and disc included: the shadow is a drop-shadow on the wrapper and the disc is created on the wrapper, at the position of the hole read with getBoundingClientRect at the moment of the blow.
  • GSAP rounds to whole pixels even strokeDashoffset: with pathLength="1" the ring jumped from empty to full. It is turned off with gsap.defaults({ autoRound: false }) and an empty plugin called autoRound.

Libraries

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

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

Testing

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