
Title rising from a line
Transitions, Text, Images
The gallery of Halden, a made-up photography studio, with six real photos of a coastline: a click on a thumbnail flies the photo from its place to the middle of the screen, measured, with a single scale and a crop that opens it without ever stretching it, while the page darkens and the caption, the counter and the buttons arrive. The arrows move to the next photo. Dragging the photo down it follows the finger, shrinks and lets the page through; released past the threshold it flies back exactly into its thumbnail on a spring, otherwise it goes back to the middle. Minimal style, a single accent.
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>
<!--
"Drag-to-close lightbox" 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>Drag-to-close lightbox</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/jetbrains-mono@5.3.0/index.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- The gallery of an invented photography studio, Halden, with six photographs of a coastline. A click on a
thumbnail flies the photo from its place to the middle of the screen while the page darkens; the arrows and the
keyboard move to the next one. Dragging the photo down makes it smaller and lets the page through, and on release
it flies back exactly into its thumbnail, or back to the middle if the pull was too short. -->
<main class="pagina">
<header class="testa" data-entra>
<p class="marca">
<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="8.5" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M3.5 13.5c3-2.6 5.6-2.6 8.5 0s5.5 2.6 8.5 0" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>
Halden Studio
</p>
<h1 class="titolo">Coastline</h1>
<p class="nota">Six photographs, autumn 2026</p>
</header>
<ul class="griglia" data-griglia>
<li><button type="button" class="miniatura" data-miniatura data-titolo="The bridge at low tide" data-luogo="Shell Bay" data-entra><img src="baia.webp" width="960" height="640" alt="A beach at low tide with a stream and a bridge under green hills"></button></li>
<li><button type="button" class="miniatura" data-miniatura data-titolo="Dry grass and open sea" data-luogo="North Head" data-entra><img src="promontorio.webp" width="960" height="720" alt="A dry grass headland above a deep blue sea"></button></li>
<li><button type="button" class="miniatura" data-miniatura data-titolo="Swell, before the wind" data-luogo="Outer Banks" data-entra><img src="mare.webp" width="960" height="638" alt="The open sea with slow waves under a pale sky"></button></li>
<li><button type="button" class="miniatura" data-miniatura data-titolo="Cliffs against the sun" data-luogo="Gull Point" data-entra><img src="scogliera.webp" width="960" height="640" alt="Dark cliffs above a bright sea with the sun low"></button></li>
<li><button type="button" class="miniatura" data-miniatura data-titolo="Reeds at the edge" data-luogo="Salt Marsh" data-entra><img src="palude.webp" width="960" height="640" alt="Golden reeds bending into still water"></button></li>
<li><button type="button" class="miniatura" data-miniatura data-titolo="Watching the breakers" data-luogo="Black Rocks" data-entra><img src="scogli.webp" width="960" height="686" alt="A person in a hat standing on mossy rocks facing the waves"></button></li>
</ul>
</main>
<div class="lb" data-lb aria-hidden="true">
<div class="lb__fondo" data-lb-fondo></div>
<div class="lb__foto" data-lb-foto role="dialog" aria-modal="true" aria-label="Photo viewer">
<div class="lb__scivola" data-lb-scivola><img data-lb-img src="baia.webp" alt=""></div>
</div>
<div class="lb__barra" data-lb-barra>
<p class="lb__didascalia"><span class="lb__titolo" data-lb-titolo></span><span class="lb__luogo" data-lb-luogo></span></p>
<p class="lb__conto" data-lb-conto></p>
</div>
<button type="button" class="lb__tasto lb__chiudi" data-lb-chiudi aria-label="Close">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6.5 6.5l11 11M17.5 6.5l-11 11" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>
</button>
<button type="button" class="lb__tasto lb__prima" data-lb-prima aria-label="Previous photo">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.5 6l-6 6 6 6" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
</button>
<button type="button" class="lb__tasto lb__dopo" data-lb-dopo aria-label="Next photo">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9.5 6l6 6-6 6" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
</button>
<p class="lb__aiuto" data-lb-aiuto>Drag down to close</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
<script src="script.js"></script>
</body>
</html>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.
18 values to change
Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI
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 “Drag-to-close lightbox” from Animorio and fit it into my siteThe open photo has a box measured again on every frame: as big as fits between the cross at the top and the caption at the bottom, with the photo’s proportions. So it holds even if the window changes size halfway through the flight.
The element is always as big as the final box; a single number, p, runs from 0 (the thumbnail) to 1 (the middle). From p come the move of the centre, a single scale, max(thumbnail / box) over the two sides, and a clip-path inset that at p = 0 crops the photo like the thumbnail (4:3, object-fit cover) and at p = 1 crops nothing: the photo never stretches.
The clip-path radius goes from the thumbnail radius divided by the scale, so on screen it stays the same, to the 6 pixels of the open photo.
Pulling down, dy follows the finger, dx follows it at half and upwards the photo resists; drag = dy / (0.45 · height) shrinks the photo (scale 1 − drag · SHRINK), lightens the backdrop and fades the caption and buttons. The finger’s speed is measured with the real time between two moves.
Past DISMISS_AT of the height, or with a quick flick, p goes back to 0 and dx, dy and the drag scale to zero together, with back.out: the photo lands exactly on its thumbnail, overshoots by a breath and settles. Otherwise only the drag goes back to zero and the photo returns to the middle.
| Name | File | Default | What it changes |
|---|---|---|---|
OPEN_TIME | script.js | 0.62 | How long the flight from the thumbnail to the middle lasts, in seconds. |
CLOSE_TIME | script.js | 0.6 | How long the flight back into the thumbnail lasts, in seconds. |
CLOSE_SPRING | script.js | 1.3 | How far the photo overshoots the thumbnail before settling (1 none, 2 a big bounce). |
DISMISS_AT | script.js | 0.16 | How far to pull down before it closes, as a share of the screen height. |
SHRINK | script.js | 0.5 | How much the photo shrinks while pulled down. |
DARKNESS | script.js | 0.92 | How dark the page gets behind the open photo (0 to 1). |
OPEN_RADIUS | script.js | 6 | The corners of the open photo, in pixels. |
AUTO_PILOT | script.js | 2.5 | After how many still seconds the gallery plays by itself (0 never). |
In the galleries of a photographer, a studio, a hotel, a restaurant or a shop: wherever a big photo opens from a grid and should close with a gesture, as on a phone.
The page is sized on the height too; the open photo takes almost the whole width and the arrows go away (keyboard and drag stay). You pull it down with a finger, with the same physics.
No flight: the lightbox opens and closes with a fade, and the next photo fades in without sliding.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, JetBrains Mono (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 7.1 KB; the libraries: GSAP 28 KB.
Tested on 27 November 2026
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.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.