Skip to content
animorio
IT
Back to the library

Achievement unlocked

SVG, PhysicsGSAPMediumCompressed weight: Demo 6.4 KBGSAP 28 KBFreeDownload the zip

The «Achievement unlocked» card of a made-up reading app, Folio: the amber hexagonal medal drops on a short cord and swings like a real damped pendulum, with the physics in GSAP’s ticker; it settles, a band of light crosses it, the achievement name rises from under a mask and the XP bar fills with the number rolling and the level ticking over. Push it with the pointer and it swings again, its shadow stretching and the light following the tilt. Then the next achievement arrives. 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>
<!--
  "Achievement unlocked" 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>Achievement unlocked</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>
  <!-- The achievement unlocked card of a made-up reading app, Folio. The medal drops on a short cord and swings like a
       real damped pendulum, settles, and a band of light crosses it; the achievement name is uncovered, the XP bar fills
       with the number rolling and the level ticking over. Push the medal with the pointer and it swings again, the light
       following its tilt. Then the next achievement comes in. -->
  <main class="stage">
    <section class="card" data-card aria-label="Folio, achievement unlocked">
      <header class="card__top">
        <span class="brand"><svg class="brand__mark" viewBox="0 0 20 20" aria-hidden="true"><path d="M3.5 4.5c2.6-.9 4.7-.6 6.5.9 1.8-1.5 3.9-1.8 6.5-.9v11c-2.6-.9-4.7-.6-6.5.9-1.8-1.5-3.9-1.8-6.5-.9z"/><path d="M10 5.4v11"/></svg>Folio</span>
        <span class="kicker" data-kicker>Achievement unlocked</span>
      </header>

      <div class="hang" data-hang>
        <svg class="medal" data-medal-svg viewBox="0 0 200 210" role="img" aria-label="Medal">
          <defs>
            <linearGradient id="face" x1="0" y1="0" x2="1" y2="1">
              <stop offset="0" stop-color="#f4c46d"/>
              <stop offset="0.55" stop-color="#e29a3a"/>
              <stop offset="1" stop-color="#c47522"/>
            </linearGradient>
            <linearGradient id="rim" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#fbe2a8"/>
              <stop offset="1" stop-color="#b2661b"/>
            </linearGradient>
            <linearGradient id="sheen" x1="0" y1="0" x2="1" y2="0">
              <stop offset="0" stop-color="#fff" stop-opacity="0"/>
              <stop offset="0.5" stop-color="#fff" stop-opacity="0.75"/>
              <stop offset="1" stop-color="#fff" stop-opacity="0"/>
            </linearGradient>
            <clipPath id="medalClip"><path d="M100 64 L148 92 L148 148 L100 176 L52 148 L52 92 Z"/></clipPath>
          </defs>
          <ellipse class="medal__shadow" data-shadow cx="100" cy="198" rx="40" ry="5"/>
          <circle class="medal__pin" cx="100" cy="10" r="4"/>
          <g data-swing>
            <path class="medal__cord" data-cord d="M100 10 L100 64"/>
            <circle class="medal__eye" cx="100" cy="62" r="4.2"/>
            <g data-body>
              <path class="medal__rim" d="M100 64 L148 92 L148 148 L100 176 L52 148 L52 92 Z"/>
              <path class="medal__face" d="M100 72 L141 96 L141 144 L100 168 L59 144 L59 96 Z"/>
              <path class="medal__etch" d="M100 80 L134 100 L134 140 L100 160 L66 140 L66 100 Z"/>
              <g class="medal__symbol" data-symbol>
                <g data-sym="book" transform="translate(0 -4.34)">
                  <path d="M80 109c7-2.4 13.5-1.6 20 3 6.5-4.6 13-5.4 20-3v29c-7-2.4-13.5-1.6-20 3-6.5-4.6-13-5.4-20-3z"/>
                  <path d="M100 112v29"/>
                </g>
                <g data-sym="moon" transform="translate(-4.4 -0.45)" style="opacity:0">
                  <path d="M108 104a17 17 0 1 0 12 26 13.5 13.5 0 0 1-12-26z"/>
                </g>
              </g>
              <g clip-path="url(#medalClip)"><rect class="medal__sheen" data-sheen x="20" y="50" width="38" height="150" fill="url(#sheen)"/></g>
            </g>
          </g>
        </svg>
      </div>

      <div class="name">
        <span class="name__mask"><span class="name__text" data-name>Seven-day reader</span></span>
        <p class="name__sub" data-sub>You read every day this week.</p>
      </div>

      <div class="xp">
        <div class="xp__row">
          <span class="xp__level">Level <span class="xp__slot"><span class="xp__col" data-level><span>4</span><span>5</span><span>6</span></span></span></span>
          <span class="xp__gain">+<span data-gain>0</span> XP</span>
        </div>
        <div class="xp__track" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="40" data-track><span class="xp__fill" data-fill></span></div>
      </div>

      <div class="actions">
        <button class="btn btn--ghost" type="button"><span class="btn__label">Share</span></button>
        <button class="btn btn--main" type="button" data-next><span class="btn__label">Continue</span></button>
      </div>
    </section>
    <svg class="pointer" data-pointer viewBox="0 0 20 20" aria-hidden="true"><path d="M4 2.5v13.2l3.6-3.4 2.4 5.4 2.3-1-2.4-5.3 5-.3z"/></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.

27 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 “Achievement unlocked” 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 background, a white card with the Folio mark and, in amber, «Achievement unlocked». An amber hexagonal medal drops from above on a short cord: the cord pulls taut and the medal bounces a little, then swings left and right like a real pendulum, less and less, until it stops. Its shadow below stretches and moves with it. The achievement name, «Seven-day reader», rises from under a mask with the line «You read every day this week.»; the XP bar fills while «+120 XP» counts up, reaches the end, the level rolls from 4 to 5 and the bar starts again. A band of light crosses the medal at a slant, and a pointer passes and pushes it: it swings again, the light following its tilt. Then the medal lifts away and «Night owl» arrives, with the moon engraved instead of the book. Share and Continue sit below.

How it works

The pendulum in the ticker

Every frame the acceleration is −ω²·sin θ − DAMP·ω: gravity on the arc and a little air. ω comes from FREQ (swings per second); the time step is capped at 33 ms, so a tab left in the background does not blow up the maths.

The cord pulling taut

The drop is a stiff spring on the cord’s length: the medal starts 46 units higher and comes down, the cord stretches a little and recovers; BOUNCE decides how much. The cord is a path redrawn from the pin to the medal.

A real pivot

The whole group, cord and medal, turns with rotate(θ 100 10), around the pin point in the viewBox: so the medal swings around the cord and not around its own centre.

Light and shadow

The band of light is a gradient rectangle, clipped by the medal’s shape, sliding across at a slant and shifting with the tilt; the shadow below follows the sine of the angle, widening and fading as the medal rises to the side.

Pushing with the pointer

The pointer’s movement over the medal, converted to viewBox units, is added to the pendulum’s speed times PUSH: the faster you pass, the more it swings.

Values to change

NameFileDefaultWhat it changes
SWINGscript.js2.6How hard the medal swings when it drops, in radians per second.
FREQscript.js1.15Swings per second of the pendulum.
DAMPscript.js1.1How quickly the swing dies down.
BOUNCEscript.js0.42How much the cord stretches and bounces when the medal lands, 0 to 1.
PUSHscript.js0.05How much a pointer pass pushes the medal.
HOLDscript.js3.4Seconds each achievement stays before the next one comes in.
AUTOPLAYscript.jstrueA pointer pushes the medal on its own, until you touch it.

Try them in the Playground

When to use it

In apps with a bit of game in them (reading, languages, workouts, habits, courses): the moment an achievement unlocks, after a streak of days or a finished challenge; also on an app’s page to show how it rewards its users.

On phones

The medal is sized on width and height (min of vw and vh, with clamp) and the card has vh paddings, so it fits whole in the phone box; a finger pushes it like the pointer, and the page does not scroll over the medal (touch-action: none).

With reduced motion

No pendulum, bounce or passing light: the medal hangs still, the name and line fade in, the bar and the level are already in place and the automatic pointer is not shown.

Pitfalls

  • The medal group turns around the pin with rotate(θ 100 10) in the SVG transform attribute: with svgOrigin on the whole svg it would turn around the wrong point.
  • The pendulum’s time step must be capped: if the tab comes back from the background with a dt of seconds, the maths blows up.
  • The pointer speed must be converted to viewBox units, otherwise the push changes with the demo’s size.
  • The level rolls in a column of digits inside a one-line window: the window has overflow hidden and a height in em, so it holds with any font.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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