Skip to content
animorio
IT
All components

Running pace calculator

Sliders, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 9.1 KBGSAP 28 KBFreeDownload the zip

The pace calculator of Stride, a made-up running app, alone in the middle on white. Pick the race among 5K, 10K, Half and Marathon with the white indicator sliding over the pills, drag the target time on a slider with ticks, and the digits of the time, the pace per kilometre and per mile roll on reels like an odometer. The effort zone (Easy, Steady, Tempo, Race) lights up in bars, and below the split times at the checkpoints are worked out again along the orange line of the race. Switch race and the pace stays while the time is recomputed. Save plan folds into “Plan saved” with a check that draws itself.

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>
<!--
  "Running pace calculator" 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>Running pace calculator</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">
    <!-- the pace calculator of a made-up running app: pick the race, drag the target time,
         and the pace per kilometre, the zone and the split times roll to the new numbers -->
    <section class="calc" data-calc aria-label="Pace calculator">
      <header class="calc__head">
        <span class="calc__title">
          <svg class="calc__icon" viewBox="0 0 24 24" aria-hidden="true">
            <circle cx="12" cy="13.5" r="7.25"></circle>
            <path d="M10 3.25h4M12 3.25v3"></path>
            <path class="calc__hand" data-hand d="M12 13.5V9.25"></path>
            <path d="M18.2 6.6l1.3-1.3"></path>
          </svg>
          <span>Pace calculator</span>
        </span>
        <span class="calc__brand">Stride</span>
      </header>

      <div class="races" role="radiogroup" aria-label="Race distance" data-races>
        <span class="races__pill" data-pill aria-hidden="true"></span>
        <button class="race" type="button" role="radio" aria-checked="false" data-race="0">5K</button>
        <button class="race" type="button" role="radio" aria-checked="false" data-race="1">10K</button>
        <button class="race" type="button" role="radio" aria-checked="false" data-race="2">Half</button>
        <button class="race" type="button" role="radio" aria-checked="true" data-race="3">Marathon</button>
      </div>

      <div class="goal">
        <span class="goal__label">Target time</span>
        <span class="goal__time roll" data-time aria-hidden="true"></span>
      </div>

      <div class="slider" data-track>
        <div class="slider__rail" aria-hidden="true">
          <span class="slider__fill" data-fill></span>
        </div>
        <div class="slider__ticks" data-ticks aria-hidden="true"></div>
        <div class="slider__handle" data-handle role="slider" tabindex="0" aria-label="Target time" aria-valuemin="0" aria-valuemax="0" aria-valuenow="0" aria-valuetext="">
          <span class="slider__halo" data-halo></span>
          <span class="slider__knob" data-knob><span class="slider__grip"></span></span>
        </div>
        <div class="slider__ends" aria-hidden="true"><span data-lo></span><span data-hi></span></div>
      </div>

      <div class="pace">
        <div class="pace__main">
          <span class="pace__label">Pace</span>
          <span class="pace__value"><span class="roll" data-pace aria-hidden="true"></span><span class="pace__unit">/km</span></span>
        </div>
        <div class="pace__side">
          <span class="zone" data-zone><span class="zone__bar"><i></i><i></i><i></i><i></i></span><span class="zone__name" data-zonename>Steady</span></span>
          <span class="pace__mile"><span class="roll roll--small" data-mile aria-hidden="true"></span><span>/mi</span></span>
        </div>
        <span class="sr" data-live aria-live="polite"></span>
      </div>

      <div class="splits" data-splits aria-label="Split times">
        <div class="splits__rail" aria-hidden="true"><span class="splits__fill" data-splitfill></span></div>
      </div>

      <button class="save" type="button" data-save data-autoclic>
        <span class="save__bg" data-savebg></span>
        <span class="save__txt" data-savetxt>Save plan</span>
        <span class="save__done" data-savedone aria-hidden="true">
          <svg viewBox="0 0 16 16"><path data-check pathLength="1" d="M3.5 8.4l2.9 2.8 6.1-6.4"></path></svg>
          <span>Plan saved</span>
        </span>
      </button>
    </section>
  </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.

28 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 “Running pace calculator” 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 white, the card of a running app: at the top a drawn stopwatch with an orange hand, “Pace calculator” and the Stride brand. Below, the four races on a grey pill track: a white indicator with a soft shadow slides under the chosen one on a spring and squashes a touch as it lands. Then the target time, large, each digit on a reel that rolls from the units up to the tens, one after another, like an odometer. The slider has ticks every five, fifteen or thirty minutes depending on the race, darker on the hours, with the fastest and slowest time at its ends; the handle is a white round with a black dot, it lifts on hover, tightens when pressed with an orange halo coming on around it, and settles with a small bounce when let go. While you drag, the pace per kilometre and per mile roll too, and the effort zone changes its name with a little hop and lights its bars. Further down the line of the race with its checkpoints: the split times roll, and when you release the handle the points give a small knock one after the other. Switch race and the line redraws from the left, the new checkpoints pop up where they fall, the ticks rise and the time is worked out again at the same pace. Save plan squashes like rubber and the label gives way to “Plan saved” with an orange check that draws itself; after a moment it goes back. The stopwatch hand turns with the time too. On its own, the demo drags the time, switches to the half, drags it, switches to the 10K and saves the plan.

How it works

Numbers on reels

Each digit is a 0 to 9 column inside a window one line tall, moved by yPercent at -10 per digit; the colons stay put. The digits roll right to left, STAGGER seconds apart, with a back.out that goes a little past. If the shape of the number changes (from 59:30 to 1:00:00) the reels are rebuilt and come in from below.

The pace stays

When you switch race the script takes the current pace (time over distance), multiplies it by the new distance and rounds it to that race’s slider step: 15 seconds for the 5K, 30 for the 10K, one minute for the half and the marathon. Then the handle glides on a spring to its new spot on the track.

The race indicator

The white pill is not inside the buttons: it is a single element under them that GSAP moves to the position and width of the chosen button, with back.out(1.25), while squashing its height on an elastic. Arrow keys step from race to race.

Split times

For each checkpoint the time is the target time times its share of the race, at an even pace. The points sit at their real distance along the line, kept inside the card at the edges, and are placed again on every resize.

The check

The check has pathLength 1 and draws itself by taking strokeDashoffset from 1 to 0; that is why autoRound is turned off at the top, otherwise GSAP would round to whole pixels and the check would appear all at once.

Values to change

NameFileDefaultWhat it changes
RACEscript.jsMarathonThe race picked at the start: 5K, 10K, Half or Marathon.
GOALscript.js3:29:00The target time at the start, for the chosen race (hours:minutes:seconds or minutes:seconds).
ROLLscript.js0.6How long the numbers take to roll to the new value, in seconds.
BOUNCEscript.js1.5How far the numbers and the handle overshoot before settling (0 = no bounce).
STAGGERscript.js0.035The delay between one digit and the next as they roll, in seconds.
SAVED_FORscript.js1.8How long “Plan saved” stays before going back to “Save plan”, in seconds.
LOOP_PAUSEscript.js1.6The pause at the end of the self-running loop before it starts again, in seconds.

Try them in the Playground

When to use it

In the app or website of a running club, a city marathon, a running shoe shop or a coach: to pick a target time and see straight away the pace to hold and the checkpoint splits. The same pattern works for any calculator where one slider changes several numbers at once.

On phones

The card takes at most the width minus 24 pixels, and the gaps between its parts and the size of the time are measured on the height too (vh), so it all fits the phone preview box. The slider drags with a finger without scrolling the page, the pills are tapped, and the checkpoints stay inside the card at the edges.

With reduced motion

No springs and no reels: the numbers change at once, the pill and the handle jump to their place without gliding, the zone changes its name without a hop, “Plan saved” appears with the check already drawn and the self-running loop does not start.

Pitfalls

  • While dragging the numbers change many times per second: every reel uses overwrite true, so the new tween replaces the old one instead of queuing.
  • The race pill must be measured on the real buttons (offsetLeft and offsetWidth) and placed again on resize: with fr columns the width changes with the card.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 24 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 components