Skip to content
animorio
IT
Back to the library

Blinking window

Images, Transitions, SVGGSAP, CSS onlyMediumCompressed weight: Demo 4.1 KBGSAP 28 KBFreeDownload the zip

A full-screen photo and, in front of it, a window showing one of its details up close, with a second close-up photo. Every now and then the window blinks: it closes into an almond and then a line, the scene changes, and it reopens on another detail. The photos are real (CC0, from StockSnap).

Rebuilt from scratch studying readingstones.com by : the idea is theirs; code, copy and images are ours. Read how it’s made

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>
<!--
  "Blinking window" 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="it">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>La finestra che sbatte le palpebre</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/standard.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="scena" data-scena>
    <!-- lo sfondo: una foto per strato, una sola visibile alla volta -->
    <svg class="sfondo" data-sfondo viewBox="0 0 1600 1000" preserveAspectRatio="xMidYMid slice" aria-hidden="true" focusable="false"></svg>

    <p class="nota" data-nota>Ogni tanto la finestra sbatte le palpebre e si riapre su un’altra scena. Premila per farlo subito.</p>

    <!-- la finestra: un dettaglio della scena in una foto ravvicinata, dentro un’apertura a mandorla -->
    <button class="finestra" type="button" data-finestra data-autoclic aria-label="Cambia scena">
      <span class="finestra__occhio" data-occhio>
        <svg class="finestra__vista" data-vista viewBox="0 0 160 90" preserveAspectRatio="xMidYMid slice" aria-hidden="true" focusable="false"><use data-uso href="#" /></svg>
      </span>
      <span class="finestra__fessura" aria-hidden="true"></span>
      <span class="finestra__angoli" aria-hidden="true"></span>
      <span class="finestra__didascalia">
        <span data-dettaglio></span>
        <span class="finestra__luogo" data-luogo></span>
      </span>
    </button>
  </main>

  <!-- le foto, messe una volta sola: le usano lo sfondo e la finestra -->
  <svg class="nascosto" aria-hidden="true" focusable="false"><defs data-scene></defs></svg>

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

8 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 “Blinking window” 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

A photo fills the screen: the sea at sunset, a cabin in the woods, a city street, a park with a kite. In front of it, a 16:9 window with four viewfinder corners shows the detail in a close-up photo: the sailboat with its red sail against the sun, the log cabin, the cat at the window, the kite in the blue sky. After a couple of seconds the window blinks: the opening narrows from top and bottom like an eye, becomes an almond and then a line of light; while it is shut, the photo behind fades into the next one, and the window reopens on the new detail. Meanwhile the detail drifts slowly and the photo behind moves closer. Pressing the window makes it blink at once.

How it works

One photo behind, one up close

The photos sit once inside a defs as SVG images: for each scene the large one (1600 by 1000, preserveAspectRatio xMidYMid slice) and the close-up (160 by 90). The background uses the large one with a full-screen use, the window uses the close-up with another use inside an SVG whose viewBox is a little tighter, so it has room to drift. The photos are swapped in the SCENE table, with the webp files in the folder.

The eyelid

The opening is a clip-path: ellipse(80% calc(var(--palpebra) × 82%) at 50% 50%). With the variable at 1 the ellipse covers the corners too; going down to 0 it narrows only in height, and the rectangle becomes first an almond and then a line. GSAP animates the CSS variable, and the same variable lights the line of light and slightly squashes the content.

The blink

A repeating timeline: 2.4 seconds open, 0.9 to close with power3.inOut, a callback that changes the scene, 0.25 in the dark, 1.1 to reopen. The scene behind fades over 0.7 seconds exactly while the window is closed, so the change is never seen with the eye open.

Alive even when still

While the window is open, the viewBox drifts by 8% of its width, like a moving shot, and the scene behind goes from scale 1 to 1.05. Pressing the window makes the timeline jump to the blink label, but only if the eyelid is open: if it is already blinking, it finishes.

Values to change

NameFileDefaultWhat it changes
SCENEscript.js4 sceneFor each scene: the place, the detail’s name, the detail’s 16:9 box and the function that draws it (SVG in 1600 × 1000).
APERTA, CHIUDE, BUIO, APREscript.js2.4, 0.9, 0.25, 1.1The seconds of the blink: eye open, closing, in the dark, reopening.
ellipse(80% … 82%)style.css80%, 82%The eyelid’s shape: narrower in width, rounder the almond.

Try them in the Playground

When to use it

To tell a place or a product through details: the overall view behind, the thing to look at in front, and a gesture that suggests a gaze. The photos are swapped in the SCENE table.

On phones

The window takes almost the full width; the background, cropped to the centre, still shows the four details, which all sit in the middle part of the scene.

With reduced motion

No blink, no drift and no zoom: the window stays open and, when pressed, scene and detail move to the next with a quarter-second fade.

Pitfalls

  • If the fade’s opacity sits on the scene group, the window that uses it inherits it too: it belongs on a group around the background’s use.
  • An ellipse that must cover the whole rectangle when open needs radii larger than half: with 80% and 82% the corners are inside.
  • The change must be a callback inside the timeline, not a separate timer: that way it stays in sync with the dark even when pressing the window jumps ahead.
  • With two photos per scene, the close-up must show the same thing as the detail in the caption: the boat, the cabin, the cat, the kite.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 7 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: Done

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