Skip to content
animorio
IT
Back to the library

Legroom compare

SVG, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.0 KBGSAP 28 KBFreeDownload the zip

The legroom of three cabins compared, on warm white: two seats in profile drawn as in a diagram, with the dimension between one and the next. Picking Economy, Premium or Business moves the rear seat away on a spring, the backs lean, the dimension stretches and the figures count. Pointing at a figure colours its part of the drawing: the dimension, or the arc of the recline being drawn.

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>
<!--
  "Legroom compare" 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>Legroom 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>
  <main class="stage">
    <!-- legroom compared across three cabins: two seats in profile, drawn as a diagram, moving apart,
         the dimension line stretching between them and the figures counting -->
    <section class="lr" data-lr aria-label="Legroom">
      <header class="lr__head"><strong>Legroom</strong><span class="lr__fare"><span data-outfare>Included</span></span></header>
      <div class="lr__seg" role="group" aria-label="Cabin" data-seg>
        <i class="lr__pick" data-pick aria-hidden="true"></i>
        <button type="button" class="lr__opt" data-cabin="0"><span>Economy</span></button>
        <button type="button" class="lr__opt" data-cabin="1"><span>Premium</span></button>
        <button type="button" class="lr__opt" data-cabin="2"><span>Business</span></button>
      </div>
      <svg class="lr__draw" viewBox="0 -18 300 136" role="img" aria-label="Two seats in profile and the distance between them" data-draw>
        <line class="floor" x1="6" y1="78" x2="294" y2="78"></line>
        <g class="seat" data-seat="0"><line class="leg" x1="22" y1="5" x2="22" y2="32"></line><rect class="pad" x="0" y="0" width="44" height="10" rx="5"></rect><g data-back><rect class="pad" x="-5" y="-54" width="10" height="59" rx="5"></rect><rect class="head" x="-7" y="-56" width="14" height="15" rx="6"></rect></g></g>
        <g class="seat" data-seat="1"><line class="leg" x1="22" y1="5" x2="22" y2="32"></line><rect class="pad" x="0" y="0" width="44" height="10" rx="5"></rect><g data-back><rect class="pad" x="-5" y="-54" width="10" height="59" rx="5"></rect><rect class="head" x="-7" y="-56" width="14" height="15" rx="6"></rect></g></g>
        <line class="ref" data-ref></line><path class="arc" data-arc pathLength="1"></path>
        <g class="dim" data-dim><line data-dimline y1="92" y2="92"></line><line data-dima y1="86" y2="98"></line><line data-dimb y1="86" y2="98"></line><text data-outdim y="112" text-anchor="middle">31 in</text></g>
      </svg>
      <div class="lr__stats">
        <button type="button" class="lr__stat" data-stat="pitch"><i>Seat pitch</i><b><span data-outpitch>31</span> in</b></button>
        <button type="button" class="lr__stat" data-stat="recline"><i>Recline</i><b><span data-outrecline>5</span>°</b></button>
        <span class="lr__stat lr__stat--plain"><i>Seat width</i><b><span data-outwidth>17.2</span> in</b></span>
      </div>
    </section>
    <span class="live" aria-live="polite" data-live></span>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.

24 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 “Legroom compare” 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 warm white, a rounded card: “Legroom” and on the right “Included”. Below, three options in a row, “Economy”, “Premium” and “Business”, the first on a white tile. Then the drawing: a floor line and two seats in profile, the front one grey and the rear one black, each with cushion, back, headrest and leg; under them, a dimension line with a tick at each end and “31 in” at its middle. At the bottom three boxes: “Seat pitch 31 in”, “Recline 5°” and “Seat width 17.2 in”. Picking “Premium” slides the tile, the rear seat moves back and settles, the backs lean a little, the dimension stretches and the numbers count to 38, 9 and 18.5; at the top the text rolls into “+$140”. With “Business” the seat nearly reaches the edge, at 60 inches, and the backs lie back. Moving the pointer onto “Recline” gives the box a teal outline and draws the arc of the recline round the seat; on “Seat pitch” the dimension is coloured.

How it works

Three numbers draw it all

Pitch, recline and width. A single function rewrites from the animated numbers the rear seat’s position, the backs’ rotation, the dimension and the figures.

The drawing is to scale

An inch is always worth the same drawing units: the distance between the seats is the real one, small. That is why the Business seat nearly reaches the edge.

Rotations in the attribute

The backs rotate round the hip by writing the transform attribute from the animated number, with the pivot in the drawing’s coordinates.

Pointing at a figure

On the pitch the dimension is coloured; on the recline an arc goes from upright to the back and is drawn with stroke-dashoffset.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#0b7f86The colour of the figure pointed at, on the drawing and in its box.
GLIDEscript.js0.9How many seconds the seats take to move apart when the cabin changes.
SPRINGscript.js1How much the tile and the seats bounce.
LOOPscript.jstrueLeft alone, the demo’s pointer tries the three cabins, points at the figures and starts again.

Try them in the Playground

When to use it

On an airline’s fare page, in the seat-selection step or on a site comparing flights; the same diagram with its stretching dimension carries a sofa’s measurements, the space between a venue’s tables, a car’s boot or a bike’s sizes.

On phones

The card is at most 348 pixels wide and about 310 tall, and narrows with the screen: the drawing is an SVG scaling as a whole. On a phone a tap on a figure points at it and another lets go. The options are 32 pixels tall.

With reduced motion

No sliding seats and no counting: on changing cabin the drawing and the numbers are the new ones at once, and pointing at the recline shows the arc already drawn. The demo’s pointer does not start.

Pitfalls

  • The figures are examples and change from aircraft to aircraft: on a real site they come from the configuration of the flight chosen, and the demo does not claim they are any airline’s.
  • The drawing has alternative text and the three figures are written below: the diagram helps, but the data reads in words. An aria-live region gives the figures on every change of cabin.
  • The rotation of an SVG group has to be written in the transform attribute with its pivot: left to transformOrigin, it is measured on the group’s box and the back turns askew.
  • The seat’s width cannot be seen in profile: it stays a number, and its box is not a button.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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