Skip to content
animorio
IT
All components

Timeline zoom slider

Sliders, Hover, PhysicsGSAP, Canvas, CSS onlyAdvancedCompressed weight: Demo 12 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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>

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

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 “Timeline zoom slider” 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 black sits the dark timeline panel of an invented video editing app: at the top the project name, Harbour cut, 48 s · 24 fps, the times of the framed stretch and an amber pill with a magnifier and the zoom. Below, the big view: the ruler with the times, the video track with six blue clips (Opening, Harbour, Gulls, Interview, Night ferry, Credits) made of frames in different tones, the teal audio track with its waveform and the amber playhead. At the bottom the overview of the whole film with an amber-edged window and two brushed-metal handles; outside the window the overview darkens. Take a handle: it widens and gets an amber halo, the window narrows and above it the clips widen, the ruler goes from five seconds to one, to half, with the new labels fading in, the waveform shows more and more detail, the clip names stay stuck to the left edge and the zoom and time digits roll with a small bounce. A few pixels from a cut, the magnet catches the handle: the cut lights up amber in the overview and in the big view and the handle gives a small click. Let go, the handle runs on a little with inertia, goes to the nearest cut and settles on a spring that overshoots by a pixel. Grabbing the window in the middle you drag it and throw it, with a sheen crossing its glass; a double tap on the overview fits the whole film again. The autopilot pointer squeezes the right handle to the cut after Gulls, the left one to the cut before Harbour, throws the window, squeezes it as tight as it goes and double taps to see everything again.

How it works

Two edges on two springs

The 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 magnet of the cuts

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 view drawn on canvas

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 rolling digits

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.

Values to change

NameFileDefaultWhat it changes
LENGTHscript.js48How long the film in the timeline is, in seconds.
MIN_SPANscript.js3The shortest stretch the zoom can squeeze to, in seconds.
SNAPscript.js10How many pixels from a cut the magnet catches the handle.
STIFFNESSscript.js260The stiffness of the handles’ spring: higher is quicker.
DAMPINGscript.js21The damping of the spring: lower overshoots more.
INERTIAscript.js0.14How far a throw carries, in seconds of its speed.
PLAYHEADscript.js18.6Where the playhead sits, in seconds; it is a magnet too.
STEPscript.js0.5How many seconds the arrow keys move a handle.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • The in-between ruler labels must divide the big ones: with 2-second steps under 5-second ones, 0:04 and 0:05 sat on top of each other. Each step has its own fine step (5 and 2.5, 10 and 5).
  • The zoom’s multiplication sign written as a backslash-u sequence became the real character through the tools: it is built with String.fromCharCode(215).
  • A huge shadow on the window to darken the rest of the overview spilled past the rounded corners: the dark part is drawn in the canvas, clipped by its rounded rectangle.
  • The spring can carry an edge past the start or the end of the film: there the edge stops and loses its speed, as against a stop.

Libraries

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.

Testing

Tested on 6 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 components