Skip to content
animorio
IT
Back to the library

Bottle compare transition

Transitions, HoverGSAP, CSS onlyAdvancedCompressed weight: Demo 11 KBGSAP 28 KBFreeDownload the zip

The passage between two pages of the online shop of a made-up bottle brand, Ostra, inside a clean browser window: from the compare page, with the Trail 600 and the City 500 side by side and their specs in rows, to the page of the chosen bottle. Tap Choose and the other bottle steps aside, the chosen tile flies and grows into the big picture of the page, the bottle tips and settles on a spring as it lands, the name, the price and the four specs of the comparison each travel to their place on the product page, the address at the top rolls over and the colours, the sizes and Add to bag arrive. Back to compare runs the journey backwards.

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>
<!--
  "Bottle compare transition" 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>Ostra, from the comparison to the chosen bottle</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 shop of a made-up bottle brand, Ostra, inside a clean browser window. The compare page sets two insulated
         bottles side by side; choosing one sends the other away, and the chosen tile, its name, its price and its three
         specs travel to their places on the product page. Back to compare runs the journey backwards -->
    <section class="win" data-win aria-label="Ostra shop">
      <span class="win__sheen" aria-hidden="true"></span>

      <div class="bar">
        <span class="bar__nav" aria-hidden="true">
          <svg viewBox="0 0 16 16"><path d="M9.8 3.8 5.6 8l4.2 4.2"></path></svg>
          <svg viewBox="0 0 16 16"><path d="M6.2 3.8 10.4 8l-4.2 4.2"></path></svg>
        </span>
        <p class="bar__url">
          <svg viewBox="0 0 16 16" aria-hidden="true"><rect x="3.6" y="7" width="8.8" height="6.4" rx="1.8"></rect><path d="M5.6 7V5.4a2.4 2.4 0 0 1 4.8 0V7"></path></svg>
          <span class="bar__host">ostra.shop/</span><span class="bar__path"><span class="bar__roll" data-url>compare</span></span>
        </p>
        <span class="bar__nav bar__nav--end" aria-hidden="true">
          <svg viewBox="0 0 16 16"><path d="M12.4 6.6A4.6 4.6 0 1 0 12.6 9.6"></path><path d="M12.8 3.6v3.2H9.6"></path></svg>
        </span>
      </div>

      <header class="head">
        <p class="brand">
          <svg class="brand__mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3.2c3.6 0 6.2 3.6 6.2 8.8S15.6 20.8 12 20.8 5.8 17.2 5.8 12 8.4 3.2 12 3.2Z"></path><path d="M8.4 9.4c2.4 1.2 4.8 1.2 7.2 0"></path></svg>
          <span>ostra</span>
        </p>
        <nav class="links" aria-label="Shop">
          <span class="links__on">Bottles</span><span>Cups</span><span>Spares</span>
        </nav>
        <p class="bag" data-bag>
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.4 5.6h9.2l-.7 7.6a1 1 0 0 1-1 .9H5.1a1 1 0 0 1-1-.9Z"></path><path d="M5.8 5.6V4.6a2.2 2.2 0 0 1 4.4 0v1"></path></svg>
          <span class="bag__n"><span class="bag__roll" data-bagn>0</span></span>
        </p>
      </header>

      <div class="body" data-body>
        <!-- the compare page -->
        <section class="cmp" data-cmp aria-label="Compare">
          <div class="cmp__head" data-chead>
            <h1 class="cmp__title">Compare</h1>
            <p class="cmp__count">Two bottles, side by side</p>
          </div>
          <div class="cols" data-cols></div>
          <div class="specs" data-specs></div>
          <div class="picks" data-picks></div>
        </section>

        <!-- the product page, filled with the chosen bottle -->
        <section class="pdp" data-pdp aria-label="Product" aria-hidden="true">
          <div class="pdp__tile tile" data-ptile>
            <span class="tile__grain" aria-hidden="true"></span>
            <span class="tile__glow" aria-hidden="true"></span>
            <span class="tile__tag" data-ptag></span>
            <span class="tile__shadow" data-pshadow aria-hidden="true"></span>
            <span class="tile__bottle" data-pbottle></span>
          </div>
          <div class="pdp__info">
            <button class="back" type="button" data-back>
              <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9.6 3.8 5.4 8l4.2 4.2"></path></svg>
              <span>Back to compare</span>
            </button>
            <p class="pdp__eye" data-peye>Insulated bottle</p>
            <h2 class="pdp__name"><span data-pname></span></h2>
            <p class="pdp__price"><span data-pprice></span><span class="pdp__per" data-pper></span></p>
            <div class="pdp__pick" data-ppick>
              <span class="sw" data-psw></span>
              <span class="seg" data-pseg></span>
            </div>
            <ul class="plist" data-plist></ul>
            <button class="add" type="button" data-add>
              <span class="add__fill" aria-hidden="true"></span>
              <svg class="add__ok" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.6 8.4 6.6 11.2 12.4 5" pathLength="1" stroke-dasharray="1 1" stroke-dashoffset="1"></path></svg>
              <span class="add__txt"><span class="add__a">Add to bag</span><span class="add__b">Added</span></span>
            </button>
          </div>
        </section>
      </div>
    </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="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.

28 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 “Bottle compare transition” 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 browser window of the Ostra shop, a made-up brand of insulated bottles: at the top the arrows, the address ostra.shop/compare in its pill and the reload key; below the mark, the links Bottles, Cups and Spares and the bag with its number in a black circle. The Compare page sets two bottles side by side, drawn with gradients, highlights and a rubber base: the sage green Trail 600 with a loop handle, on a pale green tile labelled Best for hikes, and the terracotta City 500 with a cream cap, on a pinkish tile labelled Lighter. Below are the name, the finish and the price, four spec rows (Capacity, Keeps cold, Keeps hot, Weight) with the better value in black and a small green arrow, and two Choose buttons. On hover the tile lifts by two pixels and the button fills with black from the bottom as its arrow takes a step. Tap Choose and the button presses in and springs back, the other bottle slides away to the side and fades with its specs, the title rises and fades, and the chosen tile flies up to the left and grows to fill the column of the product page: the bottle grows with it, tips a few degrees as it arrives and settles with an elastic wobble, its shadow narrowing and coming back. Meanwhile the name and the price fly to their places growing large, and the four specs of the comparison travel one after the other into the list on the page, with the hairlines drawing from the left. The address rolls to bottles/trail-600, then Back to compare, Insulated bottle, the monthly price, the three colours with a small bounce, the two sizes and the black Add to bag button arrive. Pressing it turns the button green from the left, a tick draws itself, the label slides up into Added and the bag number rolls up with a bump. Back to compare runs everything backwards, a little faster. Left alone, a drawn pointer chooses the Trail, adds it to the bag, goes back to the comparison, chooses the City and goes back again.

How it works

Two pages on top of each other, a journey measured on the spot

The comparison and the product page sit on top of each other in the same window. On click the product page is filled with the chosen bottle and the positions on both pages are measured with getBoundingClientRect: for every travelling piece (name, price, each of the specs) GSAP starts from the position and size it had in the comparison, with x, y and scale and the transformOrigin at the top left, and goes to zero. The original pieces switch off at the same instant, so you see a single object moving.

The tile that grows without stretching

The tile is not scaled: GSAP changes its real width and height, from the small size to the size of the column. The tile is a container with container-type: size and the bottle and its shadow are measured in cqh, the height of the container: they grow on their own with the tile without stretching, and the corners stay round. As it lands, the bottle turns a few degrees from its base and comes back upright with elastic.out.

The way back is the same journey in reverse

Back to compare puts the comparison back as it was, rebuilds the timeline from the measures of now, takes it to the end with progress(1) and plays it backwards with reverse, a little faster with timeScale. So the way there and the way back pass through the same points even if the window has changed size meanwhile.

Values to change

NameFileDefaultWhat it changes
TRAVELscript.js0.95How long the chosen tile takes to fly to the product page, in seconds.
LAGscript.js0.05The gap between one travelling spec and the next, in seconds.
AWAYscript.js1.4How far the other bottle moves to the side as it leaves, in em.
SETTLEscript.js4How many degrees the bottle tips when it lands, before it settles (0 for none).
BACK_SPEEDscript.js1.15How much faster the way back to the comparison runs (1 the same as the way there).
PAUSEscript.js2.4Left alone: how many seconds it stays on each product page.
LOOPscript.jstrueLeft alone, a pointer chooses a bottle, adds it to the bag, goes back and chooses the other one.
--accentstyle.css#2f6a4fThe green of the better specs and of the added button.
--inkstyle.css#17171aThe black of the words and the buttons.
--bgstyle.css#efede8The warm white around the window.

Try them in the Playground

When to use it

For an online shop with a product comparison page (bottles, headphones, mattresses, bikes): whoever has made up their mind taps the one they want and watches it arrive on its page, with the same specs they were comparing, without losing the thread; the way back puts them in the comparison as it was.

On phones

The same animation with adapted measures: the window is sized on width and height together and fits the box; on the phone you tap the tile or Choose to pick, Back to compare to go back.

With reduced motion

No movement: the two pages cross-fade into each other, Added arrives already in place and the bag number simply changes.

Pitfalls

  • In the comparison the name and the price sit below the flying tile: with the tile on top, the two travelling pieces vanished behind it. The column of words on the product page has a higher z-index than the tile.
  • A piece that starts with a transform in the CSS (the Added label below the line) and is then moved with GSAP yPercent stayed offset: GSAP reads the CSS translation as pixels and adds it. The starting state is set with GSAP only.
  • Rebuilding the way-back timeline while the comparison is still in the final state of the way there records the pieces already switched off as the start: the comparison's inline properties are cleared first, then the timeline is built and taken to progress(1).

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 11 KB; the libraries: GSAP 28 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