Skip to content
animorio
IT
Back to the library

Live lap times

Text, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.2 KBGSAP 28 KBFreeDownload the zip

Live timing at a kart track, on black: the lap time runs large and gains weight, three sectors fill and take their colour when done, the gap to the best lap updates at every sector. The finished lap drops into the list; hover it to read it again.

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>
<!--
  "Live lap times" 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>Lap times</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">
    <!-- live lap timing at a kart track: the lap time runs and gains weight, three sectors fill and take
         their colour, the gap to the best lap follows; finished laps drop into the list, hover one to read it -->
    <section class="lt" data-lt aria-label="Lap times">
      <header class="lt__head">
        <span>Circuito Alba, kart 14</span>
        <span class="lt__lap"><span class="lt__roll"><span data-lap>Lap 6</span></span></span>
      </header>

      <div class="lt__clock">
        <b class="lt__time" data-time>0:00.000</b>
        <span class="lt__gap"><span class="lt__roll"><span data-gap></span></span></span>
      </div>

      <div class="lt__sectors" data-sectors aria-hidden="true"></div>

      <div class="lt__list" data-list role="list" aria-label="Finished laps"></div>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></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.

14 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 “Live lap times” 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 black, at the top the track’s name and the lap number; below, large, the lap time running to the thousandth, its digits in cells of one width so they do not tremble, gaining weight as the lap goes on. On the right, the gap to the best lap. Three thin bars are the three sectors: each fills as the kart runs through it and shows the time to beat; when the sector ends, the bar and its time take a colour: purple if it is the best of all, green if faster than the lap before, amber if slower. At each sector the gap rolls to its new value, green or amber. On the line the time stops with a small bounce, then the lap drops to the top of the finished laps, which move down a place; the best one has the “Best” tag, the others their gap. Hovering a lap in the list, the big number and the sectors show that lap; on leaving you are back on the current lap, which never stopped.

How it works

A single clock

The lap time is a number advancing on GSAP’s ticker, multiplied by SPEED. The digits, the font weight and the fill of the three sectors all come from that number, each taking its share.

Digits in cells

Each digit sits in a cell of one width: the 1 is narrow and the 0 is wide, and without cells the number would dance at every thousandth. No tabular-nums, which gives Mona Sans a slashed zero.

Colour once the sector is done

While a sector is running its bar is neutral and shows the time to beat. The colour comes only when the sector is closed, compared with the all-time best and with the lap before.

Values to change

NameFileDefaultWhat it changes
BESTscript.js#b892ffThe colour of the best sector or lap.
UPscript.js#3ddc84The colour of a sector faster than the lap before.
DOWNscript.js#ffb020The colour of a slower sector.
SPEEDscript.js9How many times faster than real the demo’s stopwatch runs.
PAUSEscript.js0.9The seconds the lap time stands still on the line.
SPREADscript.js0.35By how many seconds at most a sector changes from lap to lap.
LOOPscript.jstrueLeft alone, a pointer moves over the finished laps.

Try them in the Playground

When to use it

On the site or app of a kart track, a circuit or a race, on the pit screen, on a motorsport event page; and wherever a time is read live against a reference: a swimming race, a run, a project’s build.

On phones

The same scene: the number is also sized on the window’s height and the laps in the list are tapped to read them again.

With reduced motion

The stopwatch runs in real time, not sped up, and the digits change in place. Laps, colours and labels change without bounces or slides.

Pitfalls

  • Track, kart and times are made up, generated from a fixed seed: in a real system they come from the track’s sensors, and the demo runs nine times faster than real to show a lap in a few seconds.
  • Colour is not the only sign: each sector writes its time, the gap has its plus or minus and the best lap has the word “Best”.
  • A number changing sixty times a second does not belong in an aria-live region: screen reader users read the finished laps in the list, which is a real list.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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