Skip to content
animorio
IT
Back to the library

Cart to summary

TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.2 KBGSAP + Flip 37 KBFreeDownload the zip

The cart of a made-up homeware shop, Kettlewood, in the clean style of today’s apps: pressing Checkout turns the same panel into the order summary. The product rows, with real photos of a stoneware mug, a candle and a notebook, shrink into thumbnails that fly into a column on the side, leaving a thin trail, the total slides to its place and grows, the fields come in staggered and Checkout stretches into Pay. Back to cart runs the way back.

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 to summary" 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 cart that turns into the order summary</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 cart of a made-up home goods shop, Kettlewood: Checkout turns the same panel into the order summary,
         the product rows (real CC0 photos) shrink into thumbnails in a column on the side, the total slides to its place and grows -->
    <div class="fit" data-fit>
      <section class="card" data-card aria-label="Kettlewood cart">
        <header class="head">
          <div class="head__a" data-head-a>
            <span class="head__title">Your cart</span>
            <span class="head__count">3 items</span>
          </div>
          <div class="head__b" data-head-b>
            <button class="back" type="button" data-back>
              <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9.8 3.6 5.4 8l4.4 4.4"/></svg>
              <span>Back to cart</span>
            </button>
            <span class="head__title">Checkout</span>
          </div>
          <span class="shop" aria-hidden="true">
            <svg viewBox="0 0 16 16"><path d="M3 13.4V7.2L8 3l5 4.2v6.2Z"/><path d="M6.6 13.4V9.8h2.8v3.6"/></svg>
            Kettlewood
          </span>
        </header>

        <div class="body">
          <aside class="side" data-side aria-hidden="true"></aside>

          <ul class="list" data-list>
            <li class="row" data-row>
              <span class="slot" data-slot><span class="thumb thumb--mug" data-thumb><img src="mug.webp" alt="A pale grey stoneware mug on a wooden table" width="320" height="320" decoding="async"></span></span>
              <span class="row__info"><span class="row__name">Stoneware mug</span><span class="row__meta">Ash, 2 x $18.00</span></span>
              <span class="row__price">$36.00</span>
            </li>
            <li class="row" data-row>
              <span class="slot" data-slot><span class="thumb thumb--candle" data-thumb><img src="candle.webp" alt="A white candle in a glass jar with a wooden wick, seen from above" width="320" height="320" decoding="async"></span></span>
              <span class="row__info"><span class="row__name">Cedar candle</span><span class="row__meta">Large, 1 x $28.00</span></span>
              <span class="row__price">$28.00</span>
            </li>
            <li class="row" data-row>
              <span class="slot" data-slot><span class="thumb thumb--book" data-thumb><img src="notebook.webp" alt="An open dotted notebook with a pen on grey linen" width="320" height="320" decoding="async"></span></span>
              <span class="row__info"><span class="row__name">Linen notebook</span><span class="row__meta">Dotted, 1 x $22.00</span></span>
              <span class="row__price">$22.00</span>
            </li>
          </ul>

          <form class="form" data-form autocomplete="off" onsubmit="return false">
            <label class="field" data-field>
              <span class="field__label">Email</span>
              <span class="field__box"><span class="field__value" data-value>ines@hollowfield.co</span></span>
            </label>
            <label class="field" data-field>
              <span class="field__label">Ship to</span>
              <span class="field__box"><span class="field__value" data-value>14 Larch Lane, Bristol</span></span>
            </label>
            <label class="field" data-field>
              <span class="field__label">Card</span>
              <span class="field__box">
                <svg class="field__card" viewBox="0 0 24 16" aria-hidden="true"><rect x="0.8" y="0.8" width="22.4" height="14.4" rx="2.4"/><path d="M0.8 5.2h22.4"/><path d="M4 11h5"/></svg>
                <span class="field__value" data-value>4242 4242 4242 4242</span>
              </span>
            </label>
          </form>
        </div>

        <div class="sum" data-sum>
          <div class="sum__line sum__line--b" data-extra><span>Subtotal</span><span>$86.00</span></div>
          <div class="sum__line sum__line--b" data-extra><span>Shipping</span><span>$7.40</span></div>
          <div class="sum__total">
            <span class="sum__label" data-sum-label><span class="sum__la">Subtotal</span><span class="sum__lb">Total</span></span>
            <span class="total" data-total><span data-total-text>$86.00</span></span>
          </div>
        </div>

        <button class="cta" type="button" data-cta>
          <span class="cta__fill" data-cta-fill></span>
          <span class="cta__label cta__label--a" data-cta-a>Checkout
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9.4"/><path d="M8.6 4 12.6 8l-4 4"/></svg>
          </span>
          <span class="cta__label cta__label--b" data-cta-b>Pay $93.40</span>
          <span class="cta__label cta__label--c" data-cta-c>
            <svg viewBox="0 0 16 16" aria-hidden="true"><path data-check d="M3.4 8.4 6.6 11.4 12.6 4.8"/></svg>
            Paid
          </span>
        </button>
      </section>
    </div>

    <svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true"><path d="M5 2.8v16.4l4.4-4.2 2.8 6.2 2.8-1.2-2.8-6.1h6.2Z"/></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/gsap@3.15.0/dist/Flip.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.

47 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 to summary” 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 cart of Kettlewood, a made-up homeware shop: Your cart, 3 items, and three rows with a small photo of the product, an ash grey stoneware mug on a wooden table, a white candle in a glass jar with a wooden wick seen from above and an open dotted notebook with a pen on grey linen, the name, the quantity and the price; below, the subtotal, $86.00, and the black Checkout button with its arrow. When Checkout is pressed, the names and prices of the rows slide away and only the thumbnails are left, flying one after another into a column on the left and leaving behind a green outline that fades; meanwhile the panel widens and becomes the order summary. At the top Checkout arrives with the Back to cart button, on the right the email, address and card fields come in staggered, below the subtotal and shipping appear, and the total slides to its place, grows and changes to $93.40 with a roll. The button stretches and its label becomes Pay $93.40; the mug’s thumbnail gets a small 2. Pressing Pay the button sinks, fills with green from the left and draws the check of Paid. Back to cart does it all backwards: the fields leave, the thumbnails go back to their rows, the names come back in and the total returns to $86.00. A drawn pointer runs the loop by itself; you can also press for real.

How it works

One panel, two states

Cart and summary are the same card: the is-b class changes the width, hides the rows and shows the side column and the fields. The thumbnails are not copied but really moved with appendChild into the column, and on the way back put back into their place in the row, a 44 pixel slot that always stays there.

Flip makes the trip

Before the change Flip.getState reads the card, the three thumbnails, the total row and the button; then the page changes and Flip.from animates each from its old position to the new one with expo.inOut, nested because they live inside the widening card, absolute for the thumbnails that change parent, and a stagger only for them.

The trail

At take-off, for each thumbnail a box with a green border is placed in the card at its starting position, measured with getBoundingClientRect and divided by the container’s scale; the box fades and shrinks in seven tenths, staggered like the thumbnails.

The total that grows

The total row travels with Flip, but the figure inside grows with its own scale tween with back.out, from the right edge; halfway the figure leaves upwards and comes back in from below with the new amount.

Pay

When Pay is pressed the button sinks to 0.97 and comes back with an elastic; a green fill widens with scaleX from the left, the label leaves upwards and Paid arrives, with its check drawn by stroke-dashoffset.

Values to change

NameFileDefaultWhat it changes
SHOPscript.js'Kettlewood'The name of the made-up shop, written in the corner of the card.
FLIP_TIMEscript.js0.9The seconds in which the cart becomes the summary, and back.
STAGGERscript.js0.06The seconds between one thumbnail and the next as they fly to the side.
GROWscript.js1.45How much the total grows in the summary.
TRAILscript.js0.45How visible the trail left by the thumbnails is (0 means no trail).
HOLDscript.js2.2The seconds Paid stays before the drawn pointer goes back to the cart.

Try them in the Playground

When to use it

For the cart of an online shop that leads to the checkout without changing page: the buyer sees their products stay with them while the form arrives, and the total never disappears.

On phones

The same animation: the card is drawn in pixels and the container scales it down as needed, on width and height, so the open summary fits whole in the box.

With reduced motion

No flight: the card fades, changes state and comes back; the payment shows Paid with its check at once, without the fill.

Pitfalls

  • The thumbnails change parent: without absolute on them Flip would make them jump when the row leaves the flow.
  • The card sits in a scaled container: getBoundingClientRect sizes must be divided by the scale before placing the trail in the card’s pixels.
  • The total changes size with a scale tween on its child and not with font-size, which Flip cannot animate.
  • Without a fixed place for the thumbnail, on the way back the row lost its first column while the thumbnail was flying and the name squeezed onto three lines: each row keeps an empty 44 pixel slot where the thumbnail lands.
  • The thumbnails are real photos cropped square at 320 pixels and shown at 44: with object-fit cover and the radius inherited from the box they stay sharp even when enlarged, and a hairline over the photo (a pseudo-element) keeps the edge of the light photos on the white card; the badge with the 2 sits above with z-index.

Libraries

GSAP 3.15.0, Flip 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 7.2 KB; the libraries: GSAP + Flip 37 KB.

Testing

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