
The layered button
Buttons, Hover, Physics
The double zoom slider in the timeline of a video editing app, on black: under the tracks sits the overview of the whole film with an amber window and two brushed-metal handles. Squeeze the handles and the clips above widen, the ruler changes step with its labels fading, the waveform shows more detail and the zoom and time digits roll; near a cut the magnet catches the handle, the cut lights up and the spring sets it down one pixel too far. The window can be thrown with inertia and a double tap fits the whole film again.
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>
<!--
"Timeline zoom slider" 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>The timeline zoom slider whose handles snap to the cuts</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" data-stage>
<!-- the zoom of a video editor's timeline: the window over the overview has two metal handles; pulling them in
zooms the clips above, they snap to the cuts with a magnet, and the numbers roll -->
<section class="editor" data-card aria-label="Timeline">
<header class="bar">
<div class="file">
<svg class="file__icon" viewBox="0 0 20 20" aria-hidden="true">
<rect x="2.5" y="4" width="15" height="12" rx="2.6"></rect>
<path d="M6.2 4v12M13.8 4v12M2.5 8h3.7M2.5 12h3.7M13.8 8h3.7M13.8 12h3.7"></path>
</svg>
<span class="file__name">Harbour cut</span>
<span class="file__meta">48 s · 24 fps</span>
</div>
<div class="readout">
<span class="readout__range" aria-hidden="true"><span class="roll" data-from></span><span class="readout__dash"></span><span class="roll" data-to></span></span>
<span class="chip" aria-live="polite">
<svg class="chip__icon" viewBox="0 0 16 16" aria-hidden="true"><circle cx="7" cy="7" r="4.2"></circle><path d="M10.2 10.2 13.6 13.6"></path><path class="chip__plus" d="M7 5.1v3.8M5.1 7h3.8"></path></svg>
<span class="roll roll--zoom" data-zoom></span>
</span>
</div>
</header>
<div class="view" data-view>
<canvas class="view__cv" data-main aria-hidden="true"></canvas>
<span class="view__edge view__edge--l" aria-hidden="true"></span>
<span class="view__edge view__edge--r" aria-hidden="true"></span>
</div>
<div class="mini" data-mini>
<canvas class="mini__cv" data-minicv aria-hidden="true"></canvas>
<div class="win" data-win aria-label="Zoom window" role="group">
<span class="win__glass" data-glass></span>
<span class="win__sheen" data-sheen></span>
<span class="grip grip--a" data-grip="a" role="slider" tabindex="0" aria-label="Zoom start" aria-valuemin="0" aria-valuemax="48" aria-valuenow="0">
<span class="grip__metal" data-metal><span class="grip__lines"></span></span>
</span>
<span class="grip grip--b" data-grip="b" role="slider" tabindex="0" aria-label="Zoom end" aria-valuemin="0" aria-valuemax="48" aria-valuenow="48">
<span class="grip__metal" data-metal><span class="grip__lines"></span></span>
</span>
</div>
</div>
<p class="hint" data-hint>Drag the handles to zoom · double tap to fit</p>
</section>
<svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></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>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
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 “Timeline zoom slider” from Animorio and fit it into my siteThe state is two times in seconds, the start and end of the window. Each has a wanted value and a drawn one that follows it on a hand-written spring in the GSAP ticker (stiffness STIFFNESS, damping DAMPING, step at most 1/30 of a second): so the window has weight while dragged and settles one pixel too far. The handles never come closer than MIN_SPAN seconds.
The cuts between clips, the two ends and the playhead are magnets. While dragging, within SNAP pixels of the nearest cut the value is pulled towards the cut by the square of the distance, so the handle sticks and unsticks without jumps; when it really catches, the cut lights up and the metal gives an elastic click. On release the pointer speed times INERTIA carries the handle further, then the nearest cut within twice SNAP captures it.
The big view and the overview are two canvases redrawn only when something moves, at the screen density. The ruler picks its step from the pixels per second and fades the in-between labels in between 30 and 56 pixels; the waveform comes from a smooth three-scale noise computed on the fly, so the tighter the zoom the more detail appears. The clip names stay stuck to the left edge of the view.
The zoom and the times are columns of digits from 0 to 9 in a one-line window, with a mask fading top and bottom: when a digit changes its column slides with back.out, the others stay still. If the shape of the number changes (from 9.9 to 10) the row is rebuilt with a fade.
| Name | File | Default | What it changes |
|---|---|---|---|
LENGTH | script.js | 48 | How long the film in the timeline is, in seconds. |
MIN_SPAN | script.js | 3 | The shortest stretch the zoom can squeeze to, in seconds. |
SNAP | script.js | 10 | How many pixels from a cut the magnet catches the handle. |
STIFFNESS | script.js | 260 | The stiffness of the handles’ spring: higher is quicker. |
DAMPING | script.js | 21 | The damping of the spring: lower overshoots more. |
INERTIA | script.js | 0.14 | How far a throw carries, in seconds of its speed. |
PLAYHEAD | script.js | 18.6 | Where the playhead sits, in seconds; it is a magnet too. |
STEP | script.js | 0.5 | How many seconds the arrow keys move a handle. |
In the timeline of a video or audio editor, in a podcast or editing app, in the player of a long recording, in a dashboard with a time chart to zoom into: anywhere you pick a stretch of something long and want the zoom to land on the points that matter.
The panel is at most 640 pixels or 92% of the screen wide; the big view is between 118 and 196 pixels tall at 33% of the height, so everything fits in the phone box. Under 460 pixels the file details and the times hide, the name and the zoom stay. The handles have 30 pixels of grip for a finger and touch-action: none, so dragging them does not scroll the page; the double tap is counted by hand because on touch dblclick does not always arrive.
No springs, inertia or clicks: the window goes straight to where you take it and the magnet sets it on the cut without a bounce; the digits change in place and the autopilot pointer stays hidden, so you only see the zooms one after another.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 12 KB; the libraries: GSAP 28 KB.
Tested on 6 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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
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.