Skip to content
animorio
IT
Back to the library

Barcode scanner

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

People searched for “barcode scanner” and found only words drawn as barcodes: here is the real scanner of a made-up grocery app, Larder, in a screen-shaped card on warm white. The viewfinder’s four thin corners search, tighten on a spring around the label of an abstract package, an orange line sweeps across the code and the bars light up one by one beneath it; the corners click inwards and the product card rises from the bottom, with the price rolling, three nutrition values as small bars and Add to list, which turns into Added while the list count goes up. On hover the values show the exact number. Minimal style.

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>
<!--
  "Barcode scanner" 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>Barcode scanner</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 scanner of a made-up grocery app, Larder: the viewfinder looks for a code, locks on it with a spring,
         a thin line reads the bars one by one, and the product card rises from the bottom -->
    <section class="screen" data-screen aria-label="Larder barcode scanner">

      <header class="bar">
        <span class="brand"><svg viewBox="0 0 18 18" aria-hidden="true"><path d="M3.2 7.4h11.6l-1.3 7.2H4.5z"></path><path d="M6.4 7.4l1.4-4.1M11.6 7.4l-1.4-4.1"></path></svg>Larder</span>
        <button class="listbtn" type="button" data-list aria-label="Shopping list">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.6 4.6h7.2M5.6 8h7.2M5.6 11.4h7.2"></path><path d="M3 4.6h.2M3 8h.2M3 11.4h.2"></path></svg>
          <span class="listbtn__txt">List</span>
          <span class="count" data-count-wrap><span class="roll" data-count></span></span>
        </button>
      </header>

      <div class="vf" data-vf>
        <div class="vf__feed" aria-hidden="true"></div>
        <div class="scene" data-scene>
          <div class="pack" data-pack>
            <div class="pack__drift" data-drift>
              <span class="pack__seam" aria-hidden="true"></span>
              <span class="pack__fold" aria-hidden="true"></span>
              <div class="label" data-label>
                <svg class="code" data-code viewBox="0 0 106 52" aria-hidden="true"></svg>
              </div>
            </div>
          </div>
        </div>
        <div class="reticle" aria-hidden="true">
          <span class="cn cn--tl" data-cn></span><span class="cn cn--tr" data-cn></span>
          <span class="cn cn--bl" data-cn></span><span class="cn cn--br" data-cn></span>
          <span class="beam" data-beam></span>
        </div>
        <p class="hint" data-hint><span data-hint-text>Point at a barcode</span></p>
      </div>

      <div class="sheet" data-sheet role="dialog" aria-label="Scanned product">
        <button class="grab" type="button" data-grab aria-label="Scan next"><span></span></button>
        <div class="prod">
          <div class="prod__text" data-in>
            <h2 class="prod__name" data-name>Oat milk, barista 1 L</h2>
            <p class="prod__meta" data-meta>Northfield Oats &middot; per 100 ml</p>
          </div>
          <span class="price"><span class="roll" data-price></span></span>
        </div>
        <ul class="nutri" data-nutri>
          <li class="row" data-row><span class="row__k">Energy</span><span class="row__bar"><span data-fill></span></span><span class="row__v"><span class="row__word" data-word></span><span class="row__exact" data-exact></span></span></li>
          <li class="row" data-row><span class="row__k">Sugars</span><span class="row__bar"><span data-fill></span></span><span class="row__v"><span class="row__word" data-word></span><span class="row__exact" data-exact></span></span></li>
          <li class="row" data-row><span class="row__k">Protein</span><span class="row__bar"><span data-fill></span></span><span class="row__v"><span class="row__word" data-word></span><span class="row__exact" data-exact></span></span></li>
        </ul>
        <button class="add" type="button" data-add>
          <span class="add__bg" data-add-bg aria-hidden="true"></span>
          <svg class="add__ico" viewBox="0 0 16 16" aria-hidden="true"><path class="add__plus" data-plus d="M8 3.6v8.8M3.6 8h8.8"></path><path class="add__tick" data-tick d="M3.6 8.3l2.9 2.9 5.9-6.1" pathLength="1"></path></svg>
          <span class="add__label" data-add-label>Add to list</span>
        </button>
      </div>
    </section>
    <p class="sr" aria-live="polite" data-live></p>
  </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.

31 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 “Barcode scanner” 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 screen-shaped card with very rounded corners and a soft layered shadow. At the top the line mark of Larder, a made-up grocery app, and on the right the List pill with the list count, 4. Below, the viewfinder: a warm blurred surface standing in for the camera, with light from above, and in the middle a package rendered abstractly, an oat-coloured block with a fold and a seam at the top, swaying slightly as if hand-held. On the white label a real EAN-13 barcode, drawn in SVG from made-up digits, with the digits below and the longer guard bars, still grey. Four thin white corners search around, breathe and drift a few pixels; then they tighten on the label with a spring that overshoots slightly, “Point at a barcode” becomes “Scanning…”, a thin orange line sweeps across the code from left to right and every bar lights up orange beneath it and settles into black. At the end the corners turn orange and click inwards, the label hops and the product card rises from the bottom while the package lifts and shrinks: Oat milk, barista 1 L, the price rolling from €0.00 to €2.49, Energy, Sugars and Protein with the bars filling on a spring and the word Low, and the black Add to list button. On hover over the card the words give way to the exact numbers, 46 kcal, 3.4 g, 1.0 g, and the bars take the accent. Pressed, the button squeezes, turns orange, the plus spins into a tick that draws itself, the label becomes Added and the list count rolls to 5 with a hop. Then the card goes down, the viewfinder relaxes and searches again, the package leaves to the left and the next one comes in from the right: Rye crispbread 250 g, €3.19, scanned but not added.

How it works

A real barcode

The twelve made-up digits become a real EAN-13: the check digit is computed with weights 1 and 3, the first digit picks the L or G parity of the six on the left, those on the right use the R code. Adjacent 1 modules become a single rectangle in the svg, and the guard bars are longer.

The viewfinder that searches and tightens

The corners have no fixed position: every frame (gsap.ticker) works out the searching box, with the breathing and drifting made of slow sines, and the label’s box measured with getBoundingClientRect. A single number, lock, goes from 0 to 1 with back.out and blends the two: past 1 the corners go inside the label and come back.

The bars that light up

The line is a single element, placed every frame on the svg at the scan fraction of its width. Each bar knows where its centre is; when the line passes it, it takes the accent and fades to black in just over half a second, so a trail stays behind the line.

The click and the card

The click is a five-pixel inset that returns with elastic.out: all four corners step in together. The card rises with yPercent from 105 to 0 and back.out, the viewfinder stage lifts and shrinks with it, the price rolls digit by digit and the bars fill with scaleX, staggered.

The exact numbers

Every value has two overlapping labels, the word and the number: the is-exact class on the card swaps them with a fade and a six-pixel step. It switches on with hover where there is a pointer, and with a tap on the phone.

Values to change

NameFileDefaultWhat it changes
PRODUCT_1script.jsOat milk, barista 1 LThe first scanned product.
PRICE_1script.js2.49Its price, in euros.
PRODUCT_2script.jsRye crispbread 250 gThe second scanned product.
PRICE_2script.js3.19Its price, in euros.
LIST_COUNTscript.js4How many things are already on the shopping list.
SEARCHscript.js6How much the viewfinder corners move while searching.
LOCK_SPRINGscript.js1.6How far the viewfinder overshoots when it tightens on the code.
SCAN_TIMEscript.js0.95How long the line takes to cross the code.
SHEET_TIMEscript.js0.7How long the product card takes to rise.
LOOP_PAUSEscript.js1.6The pause before the loop starts again.

Try them in the Playground

When to use it

In a supermarket or grocery delivery app, in an app that reads labels and nutrition facts, in a warehouse or self-checkout, or on the page presenting an app whose camera recognises products.

On phones

The screen takes the width with a margin and the window height with min(), and the spacing follows the height with clamp; under 470 pixels of height the brand line hides, so with the card open it all fits the phone preview box. Viewfinder and label are measured every frame, so they follow a size change even mid-animation. Tapping the viewfinder scans or moves to the next one, tapping the values shows the exact numbers.

With reduced motion

No springs, flights or wandering corners: the viewfinder is already tight on the code, the bars already lit and the product card already up, with price and bars in place; the exact numbers, Added and the next product arrive with a fade and the self-running loop does not start.

Pitfalls

  • A viewfinder measured only once lost the label when the card rose and the package moved: corners and line are placed every frame on the box measured at that moment.
  • GSAP on the four corners and the is-lock class for the colour: the colour lives in the CSS and is not wiped by the inline transforms.
  • With the bars animated one by one with a fixed delay, line and bars fell out of step when SCAN_TIME changed: each bar lights up when the line passes its centre.
  • The price only rolls if before and after have the same shape: it starts from €0.00 with the same digits as €2.49.

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 22 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