Skip to content
animorio
IT
Back to the library

Marble run loader

Physics, SVGGSAPMediumCompressed weight: Demo 6.8 KBGSAP 28 KBFreeDownload the zip

The export loader of a made-up design app, Fieldwork: a blue marble rolls down three thin ramps, one per step (Compressing, Uploading, Publishing), with real gravity written by hand. It speeds up along the ramp, ticks against the bumper, drops onto the ramp below with a small bounce, and at the end falls into the cup, bounces twice and rests in the middle: «Exported». The ramp it runs on lights up, the percentage follows it, and the pointer tilts the ramps a little. Minimal style, a single accent.

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>
<!--
  "Marble run loader" 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>Marble run loader</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/jetbrains-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- The export loader of a made-up design app, Fieldwork. A marble rolls down three thin ramps, one per step of the
       export (Compressing, Uploading, Publishing), with real gravity written in the GSAP ticker: it speeds up along
       each ramp, ticks against the bumper, drops onto the next ramp with a small bounce and finally falls into the
       cup, bounces twice and rests in the middle. Moving the pointer tilts the ramps a little. -->
  <main class="stage">
    <article class="loader" data-loader aria-label="Exporting project">
      <header class="loader__head">
        <div class="loader__title">
          <p class="eyebrow">Fieldwork</p>
          <h1>Exporting project</h1>
          <p class="file">Spring catalogue.fig <span>48 MB</span></p>
        </div>
        <p class="pct" aria-live="polite"><span data-pct>0</span><i>%</i></p>
      </header>

      <svg class="track" data-track viewBox="0 0 400 270" role="img" aria-label="A marble rolling down three ramps into a cup">
        <defs>
          <radialGradient id="marble-body" cx="36%" cy="32%" r="72%">
            <stop offset="0" stop-color="var(--marble-light)"/>
            <stop offset=".55" stop-color="var(--accent)"/>
            <stop offset="1" stop-color="var(--marble-deep)"/>
          </radialGradient>
          <radialGradient id="marble-shadow" cx="50%" cy="50%" r="50%">
            <stop offset="0" stop-color="var(--ink)" stop-opacity=".34"/>
            <stop offset="1" stop-color="var(--ink)" stop-opacity="0"/>
          </radialGradient>
        </defs>

        <g class="world" data-world>
          <g class="ramp" data-ramp>
            <line class="ramp__line" x1="36" y1="44" x2="290" y2="84"/>
            <line class="ramp__stop" x1="36" y1="44" x2="35" y2="34"/>
            <text class="ramp__label" x="40" y="66">Compressing</text>
          </g>
          <g class="ramp" data-ramp>
            <line class="ramp__line" x1="364" y1="112" x2="110" y2="152"/>
            <line class="ramp__stop" x1="364" y1="112" x2="365" y2="102"/>
            <text class="ramp__label" x="360" y="134" text-anchor="end">Uploading</text>
          </g>
          <g class="ramp" data-ramp>
            <line class="ramp__line" x1="36" y1="180" x2="290" y2="220"/>
            <line class="ramp__stop" x1="36" y1="180" x2="35" y2="170"/>
            <text class="ramp__label" x="40" y="202">Publishing</text>
          </g>

          <g class="cup" data-cup>
            <path class="cup__line" d="M314 232 v18 q0 6 6 6 h32 q6 0 6 -6 v-18"/>
          </g>

          <ellipse class="shadow" data-shadow cx="0" cy="0" rx="8" ry="2" fill="url(#marble-shadow)"/>

          <g class="marble" data-marble transform="translate(56 -20)">
            <circle r="9" fill="url(#marble-body)"/>
            <g data-spin>
              <path class="marble__mark" d="M -5.2 -5.2 A 7.4 7.4 0 0 1 5.2 -5.2"/>
              <circle class="marble__dot" cx="0" cy="5.6" r="1.1"/>
            </g>
            <ellipse class="marble__shine" cx="-3" cy="-3.6" rx="3.2" ry="2"/>
          </g>
        </g>
      </svg>

      <footer class="loader__foot">
        <p class="foot foot--busy" data-busy>Keep this tab open while it exports</p>
        <p class="foot foot--done" data-done aria-hidden="true">
          <span class="tick" data-tick-wrap>
            <svg viewBox="0 0 20 20" aria-hidden="true"><path data-tick d="M5.6 10.4 8.6 13.2 14.4 7.2" pathLength="1"/></svg>
          </span>
          <span>Exported to Shared / Catalogue</span>
        </p>
      </footer>
    </article>
  </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.

25 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 “Marble run loader” 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 page, the Fieldwork card: at the top «Exporting project», the file name and its size, and on the right the large percentage. Below, three thin ramps in a zig-zag, each with its bumper on the high side and its step written underneath (Compressing, Uploading, Publishing), and at the bottom a small cup. The marble drops onto the first ramp, bounces slightly and starts rolling: you see it turn from its white mark, it speeds up, and the ramp lights up blue with its name. At the end of the ramp it flies off, lands on the ramp below, which shivers half a unit on the impact, rolls backwards against the bumper, ticks off it and sets off the other way. Its shadow stays beneath on the ramp and stretches and fades as it falls. Finished ramps turn black, the percentage climbs; at the end the marble drops into the cup, bounces twice off the floor and the wall and settles in the middle: 100%, the bottom line turns into «Exported» with the check drawing itself in the blue circle. Then the marble fades and the export starts again. Moving the pointer over the card tilts the ramps a little, and the marble runs faster or slower.

How it works

The ramps

Each ramp is an SVG line: from its two ends the script works out the length, the direction d and the normal n pointing up. A rolling marble is described by a single number, s, the distance from the high end: its position is start + d·s + n·radius.

Gravity

In the GSAP ticker, with the real time between frames, the acceleration along the ramp is gravity projected on d minus friction times speed. The mark on the marble turns by speed divided by radius, so the rolling is the real one, not a timed spin.

Flight and impact

Past the end of the ramp the marble flies under gravity. When its distance from the ramp below drops to the radius, the speed splits in two: the part along the ramp stays, the part into the ramp flips sign and shrinks by BOUNCE. If it is small the marble sticks and rolls, otherwise it bounces. Every impact makes the ramp shiver by KNOCK on an elastic ease.

The bumper and the cup

If the marble rolls backwards past the high end it knocks against the bumper and comes back with BOUNCE. In the cup the walls and the floor send it back, a small spring pulls it towards the middle, and when the bounces are over an elastic ease sets it down exactly in the centre.

The tilt

The pointer turns the group of ramps by a few degrees around the centre of the drawing (svgOrigin). Gravity inside the drawing turns by the same angle, so the marble really runs faster on the ramp that drops more.

Values to change

NameFileDefaultWhat it changes
GRAVITYscript.js900How strong gravity is, in drawing units per second squared (the drawing is 400 wide).
FRICTIONscript.js0.32How much the ramps slow the marble down (0 ice, 1 felt).
BOUNCEscript.js0.42How much the marble bounces back on a ramp, a bumper or the cup.
TILTscript.js2.5How far the pointer can tilt the ramps, in degrees.
HOLDscript.js1.6How long «Exported» stays before the next export starts, in seconds.
KNOCKscript.js0.6How far a ramp shivers when the marble lands on it.
--accentstyle.css#3f57d6The single accent colour: the marble and the ramp it runs on.

Try them in the Playground

When to use it

Instead of the usual progress bar when a task has a few clear steps and takes a few seconds: exporting a project, uploading files, publishing, a backup. Wherever the wait should make people smile instead of weighing on them.

On phones

The card is sized on the width and the drawing on the height too (vh); since it is an SVG with its own units, the physics stays identical at every size. On a phone the ramps tilt as you drag your finger.

With reduced motion

No rolling and no bounces: the three steps light up one after another, the percentage goes from 0 to 33, 66 and 100, and at the end the marble appears resting in the cup with «Exported» fading in.

Pitfalls

  • The time between two frames is capped at a thirtieth of a second: after a tab left in the background the marble would jump through the ramps.
  • An impact only counts if the marble is moving into the ramp (the speed along the normal is negative): otherwise, just after landing, it would be bounced again on every frame.
  • The marble’s mark turns inside a group already moved to its centre (translate), so the rotation is around 0,0 and no transformOrigin is needed.
  • The tilt turns the drawing, but the physics lives in the ramps’ coordinates: that is why gravity is turned by the same angle, otherwise the marble would run as if the ramps had not moved.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, JetBrains Mono (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.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