Skip to content
animorio
IT
Back to the library

Version compare transition

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

The move between two screens of a made-up AI writing app, Penwell, on a near black ground: in the middle sits a bakery’s spring letter rewritten by the AI, with the original tucked under it like a sheet of paper. Compare versions: a light runs over the page, the page splits in two, the original slides out from under it and the rewrite moves the other way, tilting slightly and settling by a pixel; a seam of light opens between them, the words taken out are struck in rose, the new ones light up in green and each edit is tied to its partner by a thread a spark runs along. Hover an edit and the pair lights up while the thread says why it changed. Back to draft tucks the original under the rewrite again.

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>
<!--
  "Version 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>Penwell, draft to compare</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>
  <!-- the writing app of an invented AI, Penwell: the draft it rewrote splits in two, the original slides out from
       under it and the edits are tied across by threads of light; Back to draft folds the two pages into one again -->
  <main class="palco">
    <section class="finestra" data-finestra aria-label="Penwell">

      <header class="barra">
        <span class="marchio" aria-hidden="true">
          <svg viewBox="0 0 20 20"><path d="M10 2.6 15.4 8 10 17.4 4.6 8z" /><path d="M10 9.6v7.6" /><circle cx="10" cy="8.6" r="1.25" /></svg>
        </span>
        <span class="barra-titolo">
          <strong>Spring letter</strong>
          <span class="barra-sotto">
            <span data-sotto="bozza">Saffie’s Bakehouse · Saved</span>
            <span data-sotto="confronto">Comparing two versions</span>
          </span>
        </span>
        <span class="barra-versione" aria-hidden="true">
          <span data-ver="bozza">v2</span>
          <span data-ver="confronto">v1 / v2</span>
        </span>
      </header>

      <div class="tavolo" data-tavolo>
        <div class="cucitura" data-cucitura aria-hidden="true"><i data-cucitura-luce></i></div>

        <article class="pagina pagina--v1" data-pagina="v1" aria-label="Original version">
          <div class="pagina-luce" aria-hidden="true"></div>
          <header class="pagina-testa">
            <span class="etichetta">Original</span>
            <span class="quando">Nov 12</span>
          </header>
          <h2 class="pagina-titolo">Fresh this spring</h2>
          <p class="pagina-testo">Our new sourdough <span class="segno segno--tolto" data-segno="0">is finally here</span>. <span class="segno segno--tolto" data-segno="1">It comes out of the oven</span> every morning at 7. Come by and <span class="segno segno--tolto" data-segno="2">try a slice</span>.</p>
          <p class="pagina-testo pagina-altro">We bake rye on Fridays and almond croissants all weekend.</p>
          <p class="pagina-firma pagina-altro">See you soon, Saffie</p>
          <footer class="pagina-piede pagina-altro"><span>36 words</span><span>12 s read</span></footer>
        </article>

        <article class="pagina pagina--v2" data-pagina="v2" aria-label="Rewritten version">
          <div class="pagina-luce" aria-hidden="true"></div>
          <div class="scansione" data-scansione aria-hidden="true"></div>
          <header class="pagina-testa">
            <span class="etichetta etichetta--ai">
              <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1.8c.5 2.9 1.9 4.3 4.8 4.8-2.9.5-4.3 1.9-4.8 4.8-.5-2.9-1.9-4.3-4.8-4.8 2.9-.5 4.3-1.9 4.8-4.8z" /><path d="M12.6 10.6c.2 1.1.7 1.6 1.8 1.8-1.1.2-1.6.7-1.8 1.8-.2-1.1-.7-1.6-1.8-1.8 1.1-.2 1.6-.7 1.8-1.8z" /></svg>
              Penwell rewrite
            </span>
            <span class="quando">Just now</span>
          </header>
          <h2 class="pagina-titolo">Fresh this spring</h2>
          <p class="pagina-testo">Our new sourdough <span class="segno segno--messo" data-segno="0">has landed</span>. <span class="segno segno--messo" data-segno="1">Fresh from the oven</span> every morning at 7. Come by and <span class="segno segno--messo" data-segno="2">grab a warm slice</span>.</p>
          <p class="pagina-testo pagina-altro">We bake rye on Fridays and almond croissants all weekend.</p>
          <p class="pagina-firma pagina-altro">See you soon, Saffie</p>
          <footer class="pagina-piede pagina-altro"><span>34 words</span><span>10 s read</span></footer>
        </article>

        <svg class="fili" data-fili aria-hidden="true">
          <defs>
            <filter id="bagliore" x="-50%" y="-50%" width="200%" height="200%">
              <feGaussianBlur stdDeviation="2.4" result="b" />
              <feMerge><feMergeNode in="b" /><feMergeNode in="SourceGraphic" /></feMerge>
            </filter>
          </defs>
        </svg>

        <span class="motivo" data-motivo aria-hidden="true"></span>
      </div>

      <footer class="aiuto">
        <span class="aiuto-icona" aria-hidden="true">
          <svg viewBox="0 0 16 16"><path d="M8 1.8c.5 2.9 1.9 4.3 4.8 4.8-2.9.5-4.3 1.9-4.8 4.8-.5-2.9-1.9-4.3-4.8-4.8 2.9-.5 4.3-1.9 4.8-4.8z" /></svg>
        </span>
        <span class="aiuto-testo">
          <span data-aiuto="bozza"><strong>Penwell rewrote 3 phrases</strong><span class="aiuto-piccolo">Shorter and warmer</span></span>
          <span data-aiuto="confronto"><strong><b class="tolte" data-conta="12">12</b> words out <b class="messe" data-conta="10">10</b> in</strong><span class="aiuto-piccolo">Hover an edit to see why</span></span>
        </span>
        <button class="pulsante" type="button" data-pulsante>
          <span class="pulsante-fondo" aria-hidden="true"></span>
          <span class="pulsante-scritte">
            <span data-scritta="bozza">Compare<span class="lungo">&nbsp;versions</span></span>
            <span data-scritta="confronto">Back to draft</span>
          </span>
        </button>
      </footer>
    </section>

    <svg class="puntatore" data-puntatore viewBox="0 0 24 24" aria-hidden="true">
      <path d="M5 3.5v15.2l4.1-3.9 2.7 6.2 2.6-1.1-2.7-6.1 5.7-.3z" />
    </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.

61 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 “Version 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 near black ground sits the window of Penwell, a made-up AI writing app: at the top the nib mark, Spring letter and Saffie’s Bakehouse · Saved, and the v2 pill; in the middle a dark page with the Penwell rewrite label, the title Fresh this spring and the bakery’s letter (the new bread, the oven at 7, a slice to try), and under it, barely visible, the edge of another page; at the bottom the AI bar, Penwell rewrote 3 phrases, and the white Compare versions button. The pointer reaches the button, which swells and widens its label, and presses it: a blue light runs over the page from left to right, then the page splits in two. The original comes out from under it and moves left (on a phone, up), the rewrite moves right (down), both tilt slightly, stop a pixel past and come back. A seam of light opens between them with a spark running along it. One edit after another, the original’s removed words turn rose and get struck through, the rewrite’s new words light up green with a line underneath, and a thin thread ties the two across the gap between the pages, with a spark running along it. The top bar says Comparing two versions, the pill v1 / v2, the AI bar counts 12 words out and 10 in, the button becomes Back to draft. The pointer rests on an edit: the pair lights up, the others dim, the thread brightens and the reason appears on it, Paints the morning. Then Back to draft: the edits fade, the threads wind back, the original slides under again and the rewrite settles on top with a pixel of weight.

How it works

Two pages that never change size

The two versions are two absolute pages of the same size at all times: in the draft the rewrite sits in the middle and the original under it, scaled to 95.5% and lowered a few pixels; in the compare view they stand side by side, or one above the other when the window is narrow. So the text never reflows and GSAP only moves x, y, scale and rotation, measured in pixels and recomputed on resize.

Edits painted with two backgrounds

Each edit is a span with two gradient backgrounds: the tint and the line (struck through for removed words, underneath for new ones). Their widths are two CSS variables, --f and --s, that GSAP takes from 0% to 100%; with box-decoration-break: clone it works when an edit wraps to a new line too.

The threads between the pages

The edits are measured with getClientRects while the pages are at rest, then for each pair an SVG Bézier curve runs from the original’s edge to the rewrite’s edge, only in the gap between them. The thread draws itself with stroke-dashoffset, and a second copy with a short dash and a glow is the spark that runs along it.

Values to change

NameFileDefaultWhat it changes
APRIscript.js0.95How long the page takes to split, in seconds.
CHIUDIscript.js0.75How long the way back to the draft takes, in seconds.
INCLINAscript.js1.4How many degrees the pages tilt while they part.
SFALSAscript.js0.16The delay between one edit and the next as they get tied, in seconds.
LUCEscript.js1How visible the light is: the scan, the seam and the sparks on the threads (0 none).
SOSTAscript.js3.2How long the compare view stays open in the automatic tour, in seconds.
--lightstyle.css#a3bcffThe blue of the light: threads, seam and scan.
--outstyle.css#ff8e8eThe rose of the removed words.
--instyle.css#7fe3b8The green of the new words.

Try them in the Playground

When to use it

For a writing app, a document editor or an AI tool that rewrites text: whoever asked for a rewrite opens the comparison with the original, sees at a glance what was taken out and what was added, and hovering an edit reads why.

On phones

The same animation with adapted measures: when the window is narrow the two pages part one above the other instead of side by side, the threads run down from the upper page to the lower one, the second paragraph and the page footer hide, and the button just says Compare. A tap turns an edit on and off.

With reduced motion

No motion: on click the pages fade out and back in already in place, with the edits coloured and the threads already drawn; the way back does the same in reverse, with fades only.

Pitfalls

  • The edit positions are measured with the pages at rest: halfway through they are tilted and scaled, and getClientRects would give the wrong points. x, y, scale and rotation go to zero, the measure is taken and they are put back, all in the same frame.
  • The button labels are absolute and as wide as the button: to measure their real width right is removed for a moment, otherwise scrollWidth returns the button’s width and the new label comes out cut.

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