Skip to content
animorio
IT
Back to the library

Cart on the scale

Physics, HoverGSAP, CSS onlyAdvancedCompressed weight: Demo 13 KBGSAP 28 KBMatter.js 25 KBFreeDownload the zip

The parcel summary of a made-up pantry shop, Wexcombe Pantry, in the premium style of the interface pieces: the items of the order are clean tiles with their name, price and weight, and they really drop onto the pan of a postal scale, knock into each other and settle on top of one another. The pan sinks on its spring under the weight and bobs, the ruler needle follows it, the weight, the shipping band and the total roll to the new value. A tap on a tile takes it out of the parcel: it lifts, flies off, the other items fall into the gap and the pan springs back up.

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>
<!--
  "Cart on the scale" 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>Wexcombe Pantry, your parcel on the scale</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="page">
    <!-- the parcel summary of a made-up pantry shop, Wexcombe Pantry. The items of the order are clean tiles with their
         name, price and weight: they drop onto the pan of a postal scale and settle on top of each other, the pan sinks
         on its spring under the weight, the weight and the shipping band roll to the new value. A tap on a tile takes it
         out of the parcel: it lifts off, the others settle into the gap and the pan springs back up. -->
    <section class="card" data-card aria-label="Your parcel">
      <span class="card__grain" aria-hidden="true"></span>

      <header class="head">
        <div class="head__who">
          <svg class="head__mark" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="7.5" width="18" height="13" rx="3.2"></rect><path d="M8 7.5V6a4 4 0 0 1 8 0v1.5"></path><path d="M3 12.5h18"></path></svg>
          <div>
            <p class="head__brand">Wexcombe Pantry</p>
            <h1 class="head__title">Your parcel</h1>
          </div>
        </div>
        <p class="count"><span class="roll" data-count>0</span><span data-count-word>items</span></p>
      </header>

      <div class="well" data-well>
        <span class="well__light" aria-hidden="true"></span>
        <div class="ruler" aria-hidden="true" data-ruler></div>
        <svg class="spring" data-spring aria-hidden="true"><path data-coil></path><path data-coil-hi></path></svg>
        <span class="base" aria-hidden="true"></span>
        <div class="pan" data-pan aria-hidden="true"><span class="pan__face"></span></div>
        <div class="tiles" data-tiles></div>
        <div class="empty" data-empty>
          <p>Your parcel is empty</p>
          <button class="empty__btn" type="button" data-refill>Put it all back</button>
        </div>
        <div class="toast" data-toast role="status">
          <span class="toast__t" data-toast-t>Linen towel removed</span>
          <button class="toast__btn" type="button" data-undo>
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.6 4.2 2.8 7l2.8 2.8"></path><path d="M3.2 7h6.3a3.4 3.4 0 0 1 0 6.8H7.6"></path></svg>
            <span>Undo</span>
          </button>
        </div>
      </div>

      <div class="read">
        <div class="read__w">
          <p class="read__label">Parcel weight</p>
          <p class="read__num"><span class="roll" data-weight>0.00</span><span class="read__unit">kg</span></p>
        </div>
        <div class="read__band">
          <p class="band__name"><span data-band>Small parcel</span></p>
          <p class="band__price"><span class="roll" data-ship>€4.90</span><span> shipping</span></p>
        </div>
      </div>

      <div class="meter" aria-hidden="true">
        <div class="meter__track"><span class="meter__fill" data-fill></span></div>
        <span class="meter__tick" data-tick="2" style="--at: 25%"><i></i><b>2 kg</b></span>
        <span class="meter__tick" data-tick="5" style="--at: 62.5%"><i></i><b>5 kg</b></span>
        <span class="meter__end">8 kg</span>
      </div>

      <footer class="foot">
        <div class="foot__total">
          <p class="foot__label">Total</p>
          <p class="foot__num"><span class="roll" data-total>€0.00</span></p>
        </div>
        <button class="go" type="button" data-go>
          <span class="go__face">
            <span class="go__t" data-go-t>Checkout</span>
            <svg class="go__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9.4M8.6 4.2 12.4 8l-3.8 3.8"></path></svg>
          </span>
        </button>
      </footer>
    </section>
    <p class="sr" data-live aria-live="polite"></p>

    <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="https://cdn.jsdelivr.net/npm/matter-js@0.20.0/build/matter.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.

40 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 “Cart on the scale” 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 ground sits the white parcel card of Wexcombe Pantry, a made-up shop of pantry and kitchen goods, with a soft layered shadow and a light grain: at the top the green mark with a drawn bag, Your parcel and the pill with the number of items. In the middle there is a paper coloured well with a postal scale: the light steel pan with its two small lips at the ends, the coil spring drawn underneath, the base, and on the left a ruler with the kilos, 0, 2 and 5, with a green needle that rides up and down with the pan. The items of the order arrive one after another from above and really fall: a black cast iron pan, wide and low, two ivory stoneware bowls, the green olive oil, tall and narrow, the coffee beans in kraft paper colour and a linen towel with its weave. Each tile carries its name, price and weight. They hit the pan or each other, squash a little and spring back, turn, slide and come to rest on top of one another; the pan sinks on the spring by 5.5 pixels a kilo, the coil tightens, and at every hard knock the pan bobs and settles. Below, the parcel weight rolls digit by digit up to 5.01 kg, the shipping band goes from Small to Medium to Large parcel, with the tick just passed stretching and taking colour, the green bar follows the pan and the total rolls to €156.50. The towel, the lightest item, is the one that tips the parcel over 5 kilos. Under the pointer a tile lifts by two pixels with a longer shadow and shows the round mark to remove it; pressed, it sinks. Tapped, it lifts, straightens and flies off towards the Linen towel removed notice with Undo: the other items fall into the gap, the pan springs back up and shipping drops to Medium. Undo drops it again from above. Checkout says Label printed for a moment and the pan gives a small hop. Left alone, a drawn pointer takes the towel out and puts it back, then the pan and puts it back, and starts again.

How it works

Real rigid bodies with Matter.js, real tiles in HTML

Each item is a chamfered Matter.js rectangle as big as its tile, with a mass that grows with its weight: the engine runs in fixed 8 millisecond steps inside the GSAP ticker, and on every frame the HTML tile takes the position and rotation of its body. The name and the prices stay real text, crisp and readable, and the tile is a button that can be pressed from the keyboard too.

The pan on a hand written spring

The pan is a static body the script moves at every step with Body.setPosition and updateVelocity on, so the items on top follow it through friction. Its height follows a damped spring towards the weight of the items that have landed; every hard knock adds speed to the spring in proportion to the impact speed and the weight, and the pan bobs. The coil underneath is an SVG path redrawn every frame between the pan and the base.

Numbers in columns

Weight, shipping, total and item count are columns of digits from 0 to 9 that GSAP slides with yPercent, right to left with a small delay and a light back.out. When the shape of the number changes (from €7.90 to €12.50) the columns are rebuilt starting from the previous digits.

Values to change

NameFileDefaultWhat it changes
GRAVITYscript.js1.2The gravity in the well: higher, sharper falls.
BOUNCEscript.js0.08How much an item bounces when it hits the pan or another item.
FRICTIONscript.js0.55The friction between items: low they slide, high they stay where they fall.
SINKscript.js1How far the pan sinks for each kilo (1 means 5.5 pixels a kilo).
SPRINGscript.js1The stiffness of the pan spring: higher, the pan settles sooner.
WOBBLEscript.js0.32The damping of the spring: low it bobs for long, 1 it does not swing.
PAUSEscript.js1.6Left alone: how many seconds it waits between one gesture and the next.
LOOPscript.jstrueLeft alone, a drawn pointer takes items out and puts them back.
--accentstyle.css#1f5f46The green of the mark, the needle, the bar, the oil and the button.
--pagestyle.css#efece6The warm white of the ground.
--steelstyle.css#b8b2a6The colour of the spring.

Try them in the Playground

When to use it

For the cart or order summary of a shop that ships heavy goods by weight bands (pantry, kitchen, home, wine, plants): the shopper sees at once how much the parcel weighs and why shipping costs what it does, and works out alone that dropping the lightest item takes it down a band.

On phones

The same animation with adapted measures: the card is sized on width and height, the well is at most 40% of the screen tall and the tiles, the pan and the spring scale together; you tap a tile to take it out. Turning the phone keeps the same pile, only bigger or smaller.

With reduced motion

No movement: the pile is worked out at once, out of sight, and shown already in place with the pan still at its weight; taking out or putting back an item the tiles fade and reappear in their new place, and the numbers simply change.

Pitfalls

  • A static body moved with Body.setPosition without updateVelocity has no velocity: the pan going back up passed through the items and the one going down left them hanging for a moment. With updateVelocity on the engine knows the pan is moving and pushes it against them.
  • The pan only counts the items that have landed: counting them as soon as they left the top, the pan sank before the item touched it.

Libraries

GSAP 3.15.0, Matter.js 0.20.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 13 KB; the libraries: GSAP 28 KB, Matter.js 25 KB.

Testing

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