Skip to content
animorio
IT
Back to the library

Carpool route

SVG, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.8 KBGSAP 28 KBFreeDownload the zip

A car ride in an app for commuting together: the road colours in as the marker moves from home to the office, at every pick-up the stop lights up and one of the car’s seats fills, and below the seats taken and the CO₂ not emitted count up. With “Join this ride” the dashed stop becomes yours, the route starts again and the car arrives full.

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>
<!--
  "Carpool route" 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>Carpool route</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>
  <main class="stage">
    <!-- a shared ride to work: the route draws itself from stop to stop, the marker moves along it
         and a seat fills at every pick-up; Join this ride adds your stop and your seat -->
    <section class="cp" data-cp data-joined="false" aria-label="Carpool">
      <header class="cp__head">
        <span class="cp__title"><strong>Ride to the office</strong><span>Monday, leaves at 7:40</span></span>
        <span class="cp__seats" data-seats aria-hidden="true"><i>DA</i><i>LE</i><i>You</i><i>OM</i></span>
      </header>
      <div class="cp__map">
        <svg viewBox="0 0 320 140" role="img" aria-label="Route with three pick-ups" data-svg>
          <path class="cp__road" d="M22 112C66 112 62 38 112 38S176 104 214 92 262 30 298 30"></path>
          <path class="cp__done" pathLength="1" d="M22 112C66 112 62 38 112 38S176 104 214 92 262 30 298 30" data-route></path>
          <g class="cp__ends"><circle cx="22" cy="112" r="4.500"></circle><rect x="292.500" y="24.500" width="11" height="11" rx="3"></rect></g>
          <g data-stops></g>
          <g class="cp__car" data-car><circle r="9"></circle><circle class="cp__dot" r="3.200"></circle></g>
          <text class="cp__end" x="22" y="131" text-anchor="middle">Home</text>
          <text class="cp__end" x="298" y="52" text-anchor="middle">Office</text>
        </svg>
      </div>
      <footer class="cp__foot">
        <span class="cp__stat"><span class="cp__state"><span data-outstate>1 of 4 seats taken</span></span><span class="cp__saved"><b data-outsaved>0.0</b> kg of CO₂ not emitted</span></span>
        <button class="cp__btn" type="button" data-join aria-pressed="false"><span class="cp__face" data-face="ask">Join this ride</span><span class="cp__face" data-face="in"><svg viewBox="0 0 16 16" aria-hidden="true"><path pathLength="1" d="m3.600 8.300 2.900 2.900 5.900-6.500"></path></svg>You’re in</span></button>
      </footer>
    </section>
    <span class="live" aria-live="polite" data-live></span>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></path></svg>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.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

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Carpool route” 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 warm white, a light card: “Ride to the office”, the day and the departure time, and on the right the car’s four seats, with only the driver’s already dark. In the middle a small map: a grey road making two bends from “Home” to “Office”, with three stops marked by a circle and a name with its time; the middle one, “You 7:55”, is dashed. On opening the dark marker leaves home and the road behind it turns green. When it passes a stop the circle widens and tightens on a spring and takes a green edge, the name darkens and a seat at the top fills with initials; below, the line rolls from “1 of 4 seats taken” to 2 and 3, and the kilos of CO₂ not emitted count up. Your stop is skipped. Tapping “Join this ride” turns the button green with “You’re in” and a tick, your stop becomes solid, the route starts over and this time the green “You” seat fills as it passes: on arrival the line says “Full car, 4 of 4”. One more tap takes you off the ride.

How it works

One number for the whole map

GSAP takes a number from zero to one: how much road the car has covered. From it come the green stretch, the marker’s position (read from the path itself) and which stops have already been passed.

Stops from the path

Every stop is a fraction of the route: the script asks the path for the point and draws circle and name there. Moving the fraction keeps the stop on the road.

Seats and CO₂

When the car passes an active stop its seat fills. Every person on board is a car left at home for the rest of the way: the kilos not emitted are the kilometres shared times an average value.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#128a5eThe colour of the road covered, your seat and the button once you are in.
TRIPscript.js4.2How many seconds the marker takes to cover the whole route.
KMscript.js18How long the route is, in kilometres.
SPRINGscript.js1How much the stops and the seats bounce.

Try them in the Playground

When to use it

On the site or in the app of a carpooling service for colleagues, a company shuttle or a school walking bus; the same route with stops filling seats carries a courier’s round, the legs of a tour or the pick-ups of a home service.

On phones

The card is at most 356 pixels wide and narrows with the screen; the map is an svg that shrinks with the card and never exceeds 36 per cent of the screen’s height. The button is 124 pixels wide and 44 tall: it is thumb-sized, and nothing depends on hover.

With reduced motion

No journey: the road is already green up to the office, the marker is at its destination, the active stops are lit and the seats full, with the counts already at their final value. “Join this ride” adds or removes your seat at once. The demo’s pointer does not start.

Pitfalls

  • The marker moves by writing its transform attribute with the point read from the path: this way it always sits in the middle of the road, at every size.
  • Stop labels belong where the road does not pass: above a bend or to the side, otherwise the green line runs through them.
  • The seats taken are also written in words and read out in an aria-live region; the button is a real toggle (aria-pressed).
  • People, times, kilometres and CO₂ are invented or estimated with an average value per kilometre: in a real product they depend on the car and the actual route.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 5.8 KB; the libraries: GSAP 28 KB.

Testing

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