Skip to content
animorio
IT
All components

Exit-intent pop-up

Dialogs, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 9.4 KBGSAP 28 KBFreeDownload the zip

The pop-up that stops someone about to leave the cart: the top edge stretches towards the rising pointer, snaps as it leaves and throws in the window with the discount. The code can be copied, the closed window becomes a tab under the total, and Apply rolls the total down to the new price.

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>
<!--
  "Exit-intent pop-up" 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>Exit-intent pop-up</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">
    <!-- an exit-intent pop-up: the top edge of the cart stretches towards a pointer that is about to leave,
         snaps as it goes and throws in the offer; the code can be copied, kept as a tab or applied to the total -->
    <section class="xp" data-xp aria-label="Cart">
      <svg class="xp__shape" data-shape aria-hidden="true"><path data-edge></path></svg>
      <button class="xp__grip" data-grip type="button" aria-label="Leave the page"><i></i></button>

      <div class="xp__page" data-page>
        <header class="xp__head"><h2>Your cart</h2><span>2 items</span></header>
        <ul class="xp__rows">
          <li><i class="xp__tile xp__tile--a" aria-hidden="true"></i><span class="xp__what"><b>Linen overshirt</b><span>Sand, size M</span></span><span class="xp__price">&euro;52.00</span></li>
          <li><i class="xp__tile xp__tile--b" aria-hidden="true"></i><span class="xp__what"><b>Canvas tote</b><span>Olive</span></span><span class="xp__price">&euro;32.00</span></li>
        </ul>
        <div class="xp__total">
          <span>Total</span>
          <span class="xp__tag" data-tag></span>
          <span class="xp__sum" aria-live="polite"><span class="xp__roll"><span data-sum></span></span></span>
        </div>
        <button class="xp__pill" data-pill type="button">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2.500 6.200V3.500a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v2.700a1.800 1.800 0 0 0 0 3.600v2.700a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1V9.800a1.800 1.800 0 0 0 0-3.600Z"></path><path d="M9.800 2.900v10.200" stroke-dasharray="1.6 1.9"></path></svg>
          <span data-pill-text></span>
        </button>
        <button class="xp__go" type="button">Check out</button>
      </div>

      <div class="xp__pop" data-pop role="dialog" aria-modal="true" aria-labelledby="xp-title" tabindex="-1">
        <button class="xp__x" data-close type="button" aria-label="Close"><svg viewBox="0 0 14 14" aria-hidden="true"><path d="M3 3l8 8M11 3l-8 8"></path></svg></button>
        <p class="xp__eyebrow" data-part>Before you go</p>
        <h3 class="xp__title" id="xp-title" data-part data-title></h3>
        <p class="xp__sub" data-part>Your two items are still here. We&rsquo;ll hold this code for <b data-clock>10:00</b>.</p>
        <div class="xp__coupon" data-part data-coupon>
          <span class="xp__code" data-code aria-label="Discount code"></span>
          <button class="xp__copy" data-copy type="button"><span class="xp__roll"><span data-copy-text>Copy</span></span></button>
          <i class="xp__bar" aria-hidden="true"><b data-bar></b></i>
        </div>
        <button class="xp__apply" data-part data-apply type="button">
          <svg viewBox="0 0 18 18" aria-hidden="true"><path data-tick pathLength="1" d="M4 9.400 7.600 12.800 14 5.600"></path></svg>
          <span class="xp__roll"><span data-apply-text>Apply and check out</span></span>
        </button>
        <button class="xp__no" data-part data-no type="button">No thanks</button>
      </div>

      <i class="xp__cursor" data-cursor aria-hidden="true"><svg viewBox="0 0 22 22"><path d="M4 2.500 17.500 10l-5.900 1.700-2.700 5.800Z"></path></svg></i>
    </section>
  </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.

32 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 “Exit-intent pop-up” 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, the panel of a cart: two products, the total and a grip on top. As the pointer rises towards the top edge, the edge swells towards it like a membrane, following it sideways. The instant the pointer leaves, the edge snaps back and wobbles, the cart dims and blurs and the window springs in from the point the pointer left through: “Before you go”, “10% off your cart” with the headline widening, the dashed ticket with the code STAY10 and the time it is held for counting down. Copy makes the letters hop one after the other and the ticket turns solid green for a moment. Closed with the cross, Esc, “No thanks” or a tap on the cart, the window shrinks into a tab under the total, and opens again from there. “Apply and check out” turns green with a drawn check, the window leaves and the total rolls from €84.00 to €75.60, with the discount tag beside it.

How it works

The edge is a path

The outline of the cart is one SVG path. Its top side has a bump made of two Bézier curves: the position follows the pointer, the height grows with a power of how close it is to the edge. It is redrawn only while it moves.

One spring, two tempers

The height of the bump is a spring integrated on GSAP’s ticker: stiff and damped while it follows the pointer, soft and barely damped once it loses it, so the edge snaps and swings below and above the line before it rests.

The real exit

The signal is pointerleave through the top side of the panel; on a full page it is the document’s mouseleave with clientY at zero or less. With no pointer, the grip on the edge is a real button and does the same.

Where it comes from, where it goes

The window comes in with its transform origin at the point of the edge the pointer left through. Closed unused, it moves and scales to the centre of the tab, measured at that moment; opened again, it takes the same road back.

A real dialog

role=dialog with aria-modal, inert while closed, Tab cycling through its buttons, Esc closing and focus going back to the tab. The code’s time runs on the ticker and stops once the code is applied.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#e4572eThe colour of the offer: the eyebrow, the ticket, the tab.
GOODscript.js#159a5cThe colour of the copied code and the applied discount.
CODEscript.jsSTAY10The discount code written on the ticket.
OFFERscript.js10The discount, in percent: it changes the headline and the total after Apply.
TOTALscript.js84The cart total before the discount, in euros.
HOLD_MINscript.js10How many minutes the code is held for: the count starts at the first opening.
REACHscript.js54How many pixels from the top the edge starts stretching towards the pointer.
STRETCHscript.js15How many pixels at most the edge stretches before it snaps.
LOOPscript.jstrueLeft alone, the demo’s pointer tries to leave, copies the code, closes, reopens and applies.

Try them in the Playground

When to use it

On the cart or product page of an online shop, for someone about to leave without buying; with other words, for a blog’s newsletter signup or a service’s free trial. Once per visit: whoever closed it finds it in the tab, not in their face again.

On phones

A phone has no pointer to leave with: tap the grip on the top edge, the edge snaps and the window comes in the same way. On a real site the right signal is the back button or a fast scroll back up. Everything fits the width of the screen, with buttons 36 to 48 pixels tall.

With reduced motion

The edge stays straight, the window and the tab fade in and out, the letters do not hop and the total changes without rolling. The code’s time still counts down.

Pitfalls

  • Shop, products, prices and code are made up. The discount is fake: the total is recomputed in the script, a real shop asks its server.
  • pointerleave also fires when leaving sideways or through the bottom: check where from (the y against the panel), or the pop-up fires on every exit.
  • The demo presses the real buttons with click(), whose isTrusted is false: that way it writes to nobody’s clipboard and does not stop its own run. The clipboard is written only after a real click.
  • The demo’s pointer moves with an inline style and shrinks on click on its child: two transforms on one element, one from GSAP and one written by hand, wipe each other out.
  • An exit pop-up that returns on every mouse move really does drive people away: after the first close only the tab stays.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 20 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 components