Skip to content
animorio
IT
Back to the library

Fly-to-cart photo

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

The product page of a made-up shop, Penhallow, in the clean style of today’s apps: pressing Add to bag lifts a copy of the real photo of the steel bottle off the page, the side cart slides in from the right on a spring and the photo flies on an arc into the first row, where it lands with a small squash. The subtotal rolls digit by digit, the number on the bag jumps, the free shipping bar grows; closing the cart sends it back and the button returns to how it was.

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>
<!--
  "Fly-to-cart photo" 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 product photo that flies into the side bag</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>
    <!-- the product page of a made-up outdoor shop, Penhallow. Add to bag lifts a copy of the photo, the side bag
         slides in from the right on a spring, the photo flies on an arc into the first row, the subtotal rolls and the
         number on the bag jumps; closing the bag sends it back the way it came -->
    <div class="fit" data-fit>
      <section class="screen" data-screen aria-label="Penhallow shop">
        <header class="bar">
          <a class="brand" href="#" aria-label="Penhallow">
            <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 18 9.5 7l4 6.5L16 10l5 8z"/><path d="M3 18h18"/></svg>
            <span data-shop>Penhallow</span>
          </a>
          <nav class="links" aria-label="Sections"><span>Bottles</span><span>Packs</span><span>Camp</span></nav>
          <button class="bag" type="button" aria-label="Open bag" data-bag>
            <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5.5 8h13l-1 12h-11z"/><path d="M9 8V6.5a3 3 0 0 1 6 0V8"/></svg>
            <span class="bag__count" data-badge><span class="roll" data-badge-n></span></span>
          </button>
        </header>

        <div class="product">
          <div class="photo" data-photo>
            <div class="photo__art" data-art></div>
            <span class="photo__tag">New size</span>
          </div>
          <div class="info">
            <p class="info__kicker">Stainless steel</p>
            <h1 class="info__name" data-name>Field bottle</h1>
            <p class="info__price" data-price>$38</p>
            <div class="swatches" role="radiogroup" aria-label="Size">
              <button class="sw is-on" type="button" role="radio" aria-checked="true" data-sw="0"><span>750 ml</span></button>
              <button class="sw" type="button" role="radio" aria-checked="false" data-sw="1"><span>500 ml</span></button>
            </div>
            <p class="info__colour">Size <b data-colour>750 ml</b> · brushed steel</p>
            <button class="add" type="button" data-add>
              <span class="add__fill" data-addfill></span>
              <span class="add__label">
                <span class="add__a" data-adda>Add to bag</span>
                <span class="add__b" data-addb>
                  <svg viewBox="0 0 24 24" aria-hidden="true"><path data-check d="M5.5 12.5 10 17l8.5-9"/></svg>
                  Added
                </span>
              </span>
            </button>
            <p class="info__ship">Free shipping over $75</p>
          </div>
        </div>

        <!-- the side bag -->
        <div class="scrim" data-scrim></div>
        <aside class="drawer" data-drawer aria-label="Your bag" aria-hidden="true">
          <div class="drawer__head">
            <p class="drawer__title">Your bag <span class="drawer__n"><span class="roll" data-items-n></span> <span data-items-word>item</span></span></p>
            <button class="close" type="button" aria-label="Close bag" data-close>
              <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17"/></svg>
            </button>
          </div>
          <div class="lines" data-lines>
            <div class="line line--new" data-new>
              <span class="line__thumb" data-slot></span>
              <span class="line__text" data-newtext>
                <span class="line__name" data-newname>Field bottle</span>
                <span class="line__meta" data-newmeta>Steel · 750 ml</span>
                <span class="line__qty"><span>Qty 1</span><button class="line__remove" type="button" data-remove>Remove</button></span>
              </span>
              <span class="line__price" data-newprice>$38.00</span>
            </div>
            <div class="line" data-old>
              <span class="line__thumb line__thumb--cap"><img src="cappello.webp" alt="A navy cotton camp cap" width="448" height="512" decoding="async" draggable="false"></span>
              <span class="line__text">
                <span class="line__name">Cotton camp cap</span>
                <span class="line__meta">Navy · One size</span>
                <span class="line__qty"><span>Qty 1</span></span>
              </span>
              <span class="line__price">$24.00</span>
            </div>
          </div>
          <div class="drawer__foot">
            <div class="ship" data-shipbar>
              <p class="ship__text" data-shiptext>$51.00 away from free shipping</p>
              <span class="ship__track"><span class="ship__fill" data-shipfill></span></span>
            </div>
            <p class="sub"><span>Subtotal</span><span class="sub__v roll" data-sub></span></p>
            <button class="checkout" type="button">Checkout</button>
          </div>
        </aside>

        <!-- the copy of the photo that flies -->
        <div class="flyer" aria-hidden="true" data-flyer><div class="flyer__art" data-flyart></div></div>

        <!-- the drawn pointer of the autopilot -->
        <svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.5v15.2l4.1-3.9 2.7 6.1 2.6-1.1-2.7-6h5.6z"/></svg>
      </section>
    </div>
  </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.

44 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 “Fly-to-cart photo” 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 very light warm grey background there is the product page of Penhallow, a made-up outdoor shop: at the top the brand with its drawn mountain, three links and the bag icon with a green number, 1. On the left the real photo of the Field bottle, a brushed steel bottle with a black loop cap, on a dark table that reflects it in front of a warm wall; on the right the big name, the price, two sizes (750 ml and 500 ml) and the black Add to bag button. Picking a size, the photo fades to the smaller bottle with its spout cap and the pill makes a small bounce. Pressing Add to bag, the button squashes and springs back, fills with green from the left and says Added with a tick that draws itself; meanwhile a copy of the photo lifts off the page by a few pixels, the background dims a little and the side cart slides in from the right on a spring, with the title, the row that was already there (a navy cotton cap, also a photo) and the total arriving staggered. The first row opens and the photo flies on an arc to its place, turning slightly and shrinking; it lands with a soft squash, then the name, the chosen size and the price come in. The subtotal rolls from 24 to 62 dollars digit by digit, the number on the bag jumps and springs back, the free shipping bar grows and says how much is left. Remove slides the row away and brings the numbers back; the cross or a click on the background closes the cart, which slides back to the right while the button returns to Add to bag. A drawn pointer does it all by itself and starts again; it also really works, with the mouse, a finger and the Esc key.

How it works

The page to scale

The page is a 392 by 466 pixel screen inside a wrapper that GSAP centres and shrinks on the window’s width and height. Every position is read with getBoundingClientRect and divided by the scale, so the flight starts and lands in the screen’s own pixels even after a resize.

The real photos

The bottle is a real CC0 photo in two crops of the same shot, one per size, as webp. The page, the flying copy and the row’s thumbnail use the same image with object-fit: cover and the same object-position, so when the copy lands and the thumbnail takes its place the framing does not jump. Both photos are loaded at the start, before they are needed.

The cart sliding in

The cart is an absolute panel on the right, moved out with xPercent 104. A timeline brings it to zero with back.out(1.05), a spring that goes a hair too far and comes back, while the scrim over the page darkens and the cart’s title, row and footer come in staggered from the right.

The flight on an arc

A copy of the photo is placed over the original at the same position. A single number goes from 0 to 1 with power2.inOut and on every frame computes a quadratic curve whose control point sits ARC pixels higher: position, size, corners and rotation blend between the photo and the first row’s thumbnail, read when the cart has almost stopped.

The rolling digits

Every digit of the total and of the counts is a column from 0 to 9 inside a window one line tall. When the value changes GSAP moves with yPercent only the columns of the digits that change, from right to left, with a back.out that goes a little too far and settles.

Values to change

NameFileDefaultWhat it changes
SHOPscript.js'Penhallow'The name of the made-up shop, at the top left.
OPENscript.js0.62The seconds the cart takes to slide in from the right on its spring.
FLYscript.js0.78The seconds of the photo’s flight to the cart’s first row.
ARCscript.js70How far the flight’s arc rises above the straight line, in pixels.
ROLLscript.js0.55The seconds the digits of the total and the count take to roll.
ACCENTscript.js'#2f6f4e'The colour of the number on the bag, of the button once it has added and of the shipping bar.
HOLDscript.js1.5The seconds the cart stays open before the drawn pointer moves on.

Try them in the Playground

When to use it

For the product page of an online shop: whoever adds something sees where it went without leaving the page, checks the total and how much is left for free shipping, and goes back to browsing with one click.

On phones

The same animation with adapted sizes: the screen shrinks to the width and height of the box, the cart covers the right side as on desktop and a tap does everything a click does.

With reduced motion

No flight and no springs: the cart fades in, the thumbnail is already in its row, the digits change in place and the button changes its label with a fade; the drawn pointer is not shown.

Pitfalls

  • The landing thumbnail is read only when the cart has almost stopped: read at the start, with the panel still off to the right, the photo flew towards a point off screen and then jumped.
  • The page is shrunk with a scale: getBoundingClientRect measures must be divided by it, otherwise on a phone the photo started lower and further right than where it was.
  • The flight’s rotation has to come back to zero at the end: with a fixed starting angle the photo landed crooked and the thumbnail snapped straight.
  • The flying copy and the thumbnail need the photo’s same object-position: with the default centre the copy landed showing the bottle’s body and the thumbnail, framed higher, snapped to the cap. The cap sits on white: with mix-blend-mode multiply the white takes the warm grey of the box instead of making a square.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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