Skip to content
animorio
IT
Back to the library

Chess puzzle

Physics, SVGGSAP, CSS onlyAdvancedCompressed weight: Demo 12 KBGSAP 28 KBFreeDownload the zip

The «Puzzle of the day» card of Fianchetto, a made-up chess app: mate in one. The white rook lifts, jumps in an arc to d8 and lands with a one-pixel overshoot; the black rook it takes is knocked, tips over, falls on its side, slides spinning off the board and drops into the tray of captured pieces with two small bounces. Then the black king's square turns red and «Mate in 1» becomes «Solved» with a drawn tick. Under the pointer the white pieces rise and show their squares as thin rings; click a piece and then a square to play the move.

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>
<!--
  "Chess puzzle" 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>Fianchetto, the puzzle of the day</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/instrument-sans@5.3.0/index.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the Puzzle of the day card of Fianchetto, a made-up chess app: white to play and mate in one. The rook lifts,
       jumps in an arc up the d file and lands on d8 with a one-pixel overshoot; the black rook it takes is knocked,
       tips over, slides and spins off the board and drops down the tray of captured pieces with a small bounce; the
       black king's square turns the accent colour and Mate in 1 becomes Solved with a drawn tick. Hover a white piece
       to lift it and see its squares as thin rings; click a piece and then a square to play the move yourself -->
  <svg width="0" height="0" style="position:absolute" aria-hidden="true">
    <defs>
      <symbol id="p-pawn" viewBox="0 0 100 100">
        <path d="M50 21a11.5 11.5 0 0 1 7.4 20.3c3.8 1.5 6.1 3.4 6.1 5.9 0 2.3-2 3.5-4.9 4.2 2.4 7.9 6.4 14.1 11.2 18.6H30.2c4.8-4.5 8.8-10.7 11.2-18.6-2.9-.7-4.9-1.9-4.9-4.2 0-2.5 2.3-4.4 6.1-5.9A11.5 11.5 0 0 1 50 21z"/>
        <path d="M25.5 72h49a4 4 0 0 1 4 4v3.5a4 4 0 0 1-4 4h-49a4 4 0 0 1-4-4V76a4 4 0 0 1 4-4z"/>
        <path d="M41.5 47.2h17" fill="none" style="stroke: var(--pd)"/>
      </symbol>
      <symbol id="p-rook" viewBox="0 0 100 100">
        <path d="M29 17h9.5v7h6.5v-7h10v7h6.5v-7H71v15.5l-6.5 5V62l6 7.5h-41l6-7.5V37.5L29 32.5z"/>
        <path d="M25.5 72h49a4 4 0 0 1 4 4v3.5a4 4 0 0 1-4 4h-49a4 4 0 0 1-4-4V76a4 4 0 0 1 4-4z"/>
        <path d="M35.5 37.5h29M35.5 62h29" fill="none" style="stroke: var(--pd)"/>
      </symbol>
      <symbol id="p-knight" viewBox="0 0 100 100">
        <path d="M33 69.5c.8-9.6 4.6-15.6 10.6-20.4-5.4-.2-9.6 1.6-12.8 5.4l-6.4-5.2c1.4-6.2 5.8-12.6 12.2-16.4L35.4 24l7.2 6c14-0 25.2 10.4 26.2 27.6.3 4.8-.3 8.8-1.2 11.9z"/>
        <path d="M25.5 72h49a4 4 0 0 1 4 4v3.5a4 4 0 0 1-4 4h-49a4 4 0 0 1-4-4V76a4 4 0 0 1 4-4z"/>
        <path d="M46 39.5a2.2 2.2 0 1 0 .1 0z" style="fill: var(--pd); stroke: none"/>
        <path d="M52 32.5c6.5 2.4 10.6 8.4 11.6 16" fill="none" style="stroke: var(--pd)"/>
      </symbol>
      <symbol id="p-bishop" viewBox="0 0 100 100">
        <path d="M50 10.5a5.5 5.5 0 1 1 0 11 5.5 5.5 0 0 1 0-11z"/>
        <path d="M50 22.5c10.2 7 15.6 14.6 15.6 22.6 0 6.2-3.8 9.6-8.4 10.8 1.6 5.8 5 10.4 9.4 14.1H33.4c4.4-3.7 7.8-8.3 9.4-14.1-4.6-1.2-8.4-4.6-8.4-10.8 0-8 5.4-15.6 15.6-22.6z"/>
        <path d="M25.5 72h49a4 4 0 0 1 4 4v3.5a4 4 0 0 1-4 4h-49a4 4 0 0 1-4-4V76a4 4 0 0 1 4-4z"/>
        <path d="M55.5 33.5 46 44M42 56h16" fill="none" style="stroke: var(--pd)"/>
      </symbol>
      <symbol id="p-queen" viewBox="0 0 100 100">
        <path d="M22 26.5a4.5 4.5 0 1 1 .1 0zM36 19.5a4.5 4.5 0 1 1 .1 0zM50 16.5a4.5 4.5 0 1 1 .1 0zM64 19.5a4.5 4.5 0 1 1 .1 0zM78 26.5a4.5 4.5 0 1 1 .1 0z"/>
        <path d="M23.5 31 34 51l2.2-24.5L45.6 49 50 22l4.4 27 9.4-22.5L66 51l10.5-20-4.8 27.5c-.9 3.8-1.4 7.4-.7 11H29c.7-3.6.2-7.2-.7-11z"/>
        <path d="M25.5 72h49a4 4 0 0 1 4 4v3.5a4 4 0 0 1-4 4h-49a4 4 0 0 1-4-4V76a4 4 0 0 1 4-4z"/>
        <path d="M30 60h40" fill="none" style="stroke: var(--pd)"/>
      </symbol>
      <symbol id="p-king" viewBox="0 0 100 100">
        <path d="M47.2 7.5h5.6v5.4h5.4v5.6h-5.4v6.2h-5.6v-6.2h-5.4v-5.6h5.4z"/>
        <path d="M50 27c-8.6 0-15 5.2-15 11.6 0 5 3 9 7.2 11.2-2 8.2-5.6 14.4-11 19.7h37.6c-5.4-5.3-9-11.5-11-19.7 4.2-2.2 7.2-6.2 7.2-11.2C65 32.2 58.6 27 50 27z"/>
        <path d="M25.5 72h49a4 4 0 0 1 4 4v3.5a4 4 0 0 1-4 4h-49a4 4 0 0 1-4-4V76a4 4 0 0 1 4-4z"/>
        <path d="M42 50.5h16" fill="none" style="stroke: var(--pd)"/>
      </symbol>
    </defs>
  </svg>

  <main class="stage" data-stage>
    <article class="card" data-card aria-label="Fianchetto, puzzle of the day">
      <header class="head">
        <span class="mark" aria-hidden="true">
          <svg viewBox="0 0 24 24"><rect x="2" y="2" width="20" height="20" rx="6"/><path class="mark__sq" d="M7 7h5v5H7z"/><path class="mark__hot" d="M12 12h5v5h-5z"/></svg>
        </span>
        <div class="head__text">
          <p class="brand">Fianchetto</p>
          <h1 class="title">Puzzle of the day</h1>
        </div>
        <p class="date">Wed, Nov 18</p>
      </header>

      <div class="table" data-table>
        <div class="tray" data-tray aria-label="Captured pieces"><span class="tray__groove"></span></div>
        <div class="board" data-board role="grid" aria-label="Chessboard, white to play">
          <div class="squares" aria-hidden="true"></div>
          <div class="marks" data-marks aria-hidden="true"></div>
          <div class="coords" data-coords aria-hidden="true"></div>
          <div class="pieces" data-pieces></div>
        </div>
      </div>

      <footer class="foot">
        <div class="turn">
          <span class="turn__swatch" aria-hidden="true"></span>
          <span class="turn__text" data-turn>White to play</span>
        </div>
        <div class="goal" data-goal>
          <span class="goal__bg" data-goalbg></span>
          <span class="goal__face goal__face--todo" data-todo>Mate in 1</span>
          <span class="goal__face goal__face--done" data-done>
            <svg class="tick" viewBox="0 0 16 16" aria-hidden="true"><path data-tick d="M3.4 8.6 6.6 11.6 12.8 4.8"/></svg>
            Solved
          </span>
        </div>
        <div class="rating">
          <span class="rating__label">Rating</span>
          <span class="rating__num" data-rating>1842</span>
          <span class="rating__gain" data-gain>+8</span>
        </div>
      </footer>
    </article>
    <p class="hint" data-hint>Hover a white piece, click it, then a square</p>
  </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.

31 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 “Chess puzzle” 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 cream background with a soft light in the middle, the card of Fianchetto, a made-up chess app: at the top the mark, «Puzzle of the day» and the date; in the middle the board in two warm tones, cream and light wood, with a thin edge, a soft shadow and the coordinates a–h and 1–8 tiny in the corners of the edge squares; on the left the sunken tray of the captured pieces; below «White to play», the «Mate in 1» pill and the rating, 1842. The pieces are solid shapes drawn in SVG, ivory with dark outlines and warm black: king, queen, rook, knight and three pawns for white, king, rook, bishop and three pawns for black, in the position of a back-rank mate. On opening the card settles and the pieces are set down one rank after the other. Then the white rook lifts (its ground shadow widens and fades), the rings of its squares open, the one on d8 tightens and the rook jumps in an arc up the d file, growing as it rises, and lands one pixel too far and settles. Just before, the black rook is knocked: it tips on the edge of its base, falls on its side with a small bounce, slides to the left spinning and slowing with friction, leaves the board and drops down into the tray, bounces twice and rests lying down, smaller. The two squares of the move take a warm yellow, the black king's square turns red, the king flinches, below it reads «Rxd8, checkmate», the pill turns over and goes red with «Solved» and a tick that draws itself, the rating counts up to 1850 and «+8» appears. After a few seconds the rook goes home, the black one comes back on d8 and the puzzle starts again. With the pointer over a white piece the piece rises by a breath and its squares show as thin rings (larger around the pieces it could take); click the piece and then a square: the right move plays the whole thing, a wrong one goes to the square, shakes and comes back with «Not this one».

How it works

A piece is a square

Every piece is a box one square big, moved with translate in percent of its own size: 100% is one square. So the position is written in squares (x the file, y the row from the top), the board can change size whenever it likes and nothing has to be worked out again in pixels. Inside the box, the ground shadow and one layer for height and rotation holding the SVG drawing.

The jump: ground and height

The jump is two numbers: the ground position, going from d1 to d8 with power2.inOut, and the height, rising with sine.out and falling with power2.in. The height lifts the drawing, enlarges it a little and widens and fades the shadow, which stays on the ground. On landing the height goes one pixel below zero in 0.06 s and comes back in 0.36 s.

The falling rook, simulated

The taken rook has a small simulation of its own, in squares and seconds, in a GSAP ticker. First it tips on the left edge of its base: a turn around the middle plus the shift that makes it a turn around the edge, with a push that grows with the sine of the angle, and at 90 degrees it bounces back with 28% of its speed. Then it slides: friction slows it down and the spin follows. Past the edge it falls into the tray with gravity and bounces with 32% of its speed, while it shrinks and lies flat.

The possible squares

The squares of every white piece are worked out as in chess (sliding for rook, bishop and queen up to the first piece, knight jumps, king steps, pawn step and capture), without looking for checks on its own king: for the rings that is enough. The rings open from the piece outward, nearest first, with back.out.

The puzzle solved

After the landing, one timeline: the squares of the move, the king's square taking the colour, the king flinching with GSAP keyframes, the line naming the move, the pill turning over with the tick drawn by strokeDashoffset and the rating counting up. Then a delayedCall brings everything back to the start and the autopilot plays again.

Values to change

NameFileDefaultWhat it changes
JUMPscript.js0.72Seconds of the rook's jump from d1 to d8.
ARCscript.js0.55Height of the jump's arc, in squares.
HOVER_LIFTscript.js0.06How far a piece rises under the pointer, in squares.
KNOCKscript.js5.2Speed the taken rook slides away at, in squares per second.
FRICTIONscript.js3.4How hard the board slows it down.
GRAVITYscript.js16How fast it falls down the tray.
BOUNCEscript.js0.32How much speed it keeps on each bounce in the tray.
HOLDscript.js3.2Seconds the solved puzzle stays before it starts again.
WAITscript.js1.4Seconds before the puzzle plays by itself.

Try them in the Playground

When to use it

For a chess or board game app, the puzzle of the day widget of a puzzle site, the page of a chess club or a tournament, the onboarding of an app that teaches the game. The taken piece falling into the tray gives weight to the right move with no need for confetti.

On phones

The same. The board is sized on the smallest of 62% of the width, 50% of the height and 440 pixels, and the whole card, tray and words included, follows it. Without a pointer there is no hover: tap a white piece, its squares show, then tap the square.

With reduced motion

No jumps and no falls: the rook fades from d1 and appears on d8, the taken one fades and appears lying in the tray, the king's square, the «Solved» pill and the rating fade in. A wrong move only makes the piece blink.

Pitfalls

  • A CSS rotation turns around transform-origin: to make the rook fall on the edge of its base without changing the origin halfway, every frame turns it around the middle and adds the shift p − R·p, where p is the edge seen from the middle.
  • The white rook must reach d8 when the black one is already down: the knock starts 0.4 s before the landing, or for a frame the two pieces share the square.
  • With the height one pixel below zero the piece must not shrink nor darken its shadow: the drawing only uses the positive part of the height, the extra pixel is only a shift.
  • A taken piece stays in the list of pieces for the animation but must not count on the squares anymore: it has a «gone» flag and the square lookup skips it.

Libraries

GSAP 3.15.0, Instrument Sans (font variabile) 5.3.0, Geist Mono (font variabile) 5.3.0.

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

Testing

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