Skip to content
animorio
IT
All components

Water counter

Counters, Hover, PhysicsGSAP, CanvasMediumCompressed weight: Demo 9.9 KBGSAP 28 KBFreeDownload the zip

The water intake counter of a health app, in the style of product interface pieces, on white: a glass drawn like a real one, with the thickness of its walls, a solid refracting base and the window’s reflections; at every tap on «+ 250 ml» a stream of water comes down from above, splashes, sloshes the surface from side to side and settles with a meniscus on the walls and a few bubbles rising. The total «0.75 / 2 L» rolls like a counter, the day’s glass ticks light up, and at the goal the ticks make a wave.

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>
<!--
  "Water counter" 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>The water counter with the glass that fills up</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" data-stage>
    <!-- a health app's water counter: every tap pours 250 ml into a real glass,
         the water splashes, sloshes and settles; the total rolls and the day's glasses light up -->
    <section class="card" data-card aria-label="Water today">
      <header class="card__top">
        <span class="card__app">
          <svg class="card__drop" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1.6C6 4.6 3.6 7.2 3.6 9.9a4.4 4.4 0 0 0 8.8 0C12.4 7.2 10 4.6 8 1.6Z"/></svg>
          Tidewell
        </span>
        <span class="card__heads">
          <span class="card__head" data-head-day>Water today</span>
          <span class="card__head card__head--goal" data-head-goal aria-hidden="true">Goal reached</span>
        </span>
      </header>

      <p class="total" aria-live="polite">
        <span class="total__num" data-num aria-label="0.75 litres"></span>
        <span class="total__goal">/ <span data-goal-l>2</span> L</span>
      </p>

      <div class="glass" data-glass>
        <canvas data-canvas aria-hidden="true"></canvas>
      </div>

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

      <div class="actions">
        <button class="add" type="button" data-add>
          <span class="add__fill" aria-hidden="true"></span>
          <svg class="add__plus" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg>
          <span><span data-sip>250</span> ml</span>
        </button>
        <button class="reset" type="button" data-reset>New day</button>
      </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.

22 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 “Water counter” 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 there is the card of Tidewell, an invented health app: at the top the name with its drop and «Water today», below it the large total «0.75 / 2 L», in the middle a glass and below it eight ticks, one per glass of the day, the first three already blue; at the bottom the black «+ 250 ml» button and «New day». The glass is drawn on a canvas like a real one: wider at the top, both walls with their thickness, the rim catching light on top, a solid glass base with a bright crescent on its edge, the shadow on the table tinted slightly blue where the light passes through the water, two long window reflections on the left and a thin one on the right. On tap the button gives and springs back and a flash of blue runs through it; a stream of water comes down from above, fading in, hits the surface, throws up a few drops and pushes the water to one side while the level rises. The surface columns are springs linked to each other: the wave starts where the stream lands and spreads, and the whole body of water sloshes from side to side and slowly comes to rest. At the walls the water climbs a hair (the meniscus), the top face is seen slightly from above with a line of light at its front, under the surface the wall looks thicker from refraction and a few bubbles are carried down by the stream and then wobble back up. The total rolls digit by digit from right to left and the new tick lights up with a hop; at 2 L «Water today» leaves and «Goal reached» arrives, and the ticks make a wave. «New day» empties the glass and brings everything back to zero. A drawn pointer runs the loop by itself; at the first real touch it steps aside.

How it works

The glass on a canvas

The glass is drawn every frame on a canvas the size of its box, scaled by devicePixelRatio. Every measurement is a proportion of the box: the rim at 8 per cent of the height, the bottom at 95, the half width from 0.4 to 0.31 of the width, the walls 2.2 per cent thick and the solid base 11. The ellipses of the rim, the surface and the floor are 13 per cent as tall as they are wide: that is the slightly-from-above point of view.

A surface made of springs

The surface is made of 49 columns. Each is a spring pulling back to zero (stiffness 90, damping 3.2) and pulled by its two neighbours (260): a push in one place becomes a spreading wave. Separately there is a slow oscillation, a single spring, that tilts the whole surface from side to side: the stream pushes it while falling and the last splash pushes it harder.

The stream and the splash

The stream is a timeline: its head comes down from above in 0.16 seconds, the level rises with sine.inOut for the whole of POUR, then its tail drops into the water in two tenths. While the stream is landing, every frame it gives the columns under it a small push, throws drops that fall with gravity and carries a few bubbles down, which then wobble back up.

Glass that looks like glass

The glass is a few layers: the two walls filled a faint bluish grey (darker on the shaded side), the base with a horizontal gradient, a white crescent on its lower edge, the rim with light on its upper side, two reflection lines with a vertical gradient that makes them appear and fade, and under the surface a thicker blue line along the walls for refraction.

The rolling total

The number is made of windows one line tall, one per digit, each holding a column from 0 to 9: to show a 7 the column moves up 70 per cent. The digits start from the right, six hundredths apart, with back.out to pass the mark by a pixel; the windows have a soft mask top and bottom, so two digits are never readable at once.

Values to change

NameFileDefaultWhat it changes
GOALscript.js2The day’s goal, in litres: the full glass.
SIPscript.js250How much water each tap adds, in millilitres.
STARTscript.js750How much water has already been drunk when it opens, in millilitres.
POURscript.js0.9How long the pouring stream lasts, in seconds.
SLOSHscript.js1How much the water sloshes when it lands (0 = still).
BUBBLESscript.js10How many bubbles rise with each pour.
ACCENTscript.js#2f7cf6The blue of the water, the ticks and the button.

Try them in the Playground

When to use it

For a health, wellness or workout app that counts the water you drink, or for any counter of an amount building up towards a goal (coffees, portions, savings): the glass filling up says progress better than a bar.

On phones

On the phone the glass is sized on the height too (at most 34-37 per cent of the screen) and the card stays at most 300 pixels wide with a 16-pixel margin; there is no hover, everything else is the same.

With reduced motion

No stream, waves, drops or bubbles: the level rises in a moment, the total changes with a fade, the ticks light up without a hop and the drawn pointer is not shown.

Pitfalls

  • The surface simulation takes two half steps per frame with time capped at 33 milliseconds: with a single step and a tab coming back after a while, the springs blow up.
  • The stream fades in from above with a vertical gradient: drawn solid, it would start on the canvas edge, cut off sharply.
  • The total’s digits avoid Mona Sans’s tabular figures (the zero comes out slashed): each digit sits in a 0.6 em wide window, centred.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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