Command Palette

Search for a command to run...

Hectal
Shots in this scene
SHOT 0.3Beginner ~22 min · shot 3 of 6

The Editor and the Motion Timeline

In one line

Every live example has an editor, a viewfinder that shows the page, and the Motion Timeline under it. The timeline can pause the page, slow it down, step one frame at a time and scrub, and it shows every running animation as a track coloured by its cost.

0/6 · 0%

Think of it like this

A referee who is unsure about a goal watches the replay in slow motion, frame by frame. At full speed the ball crosses the line in a blur; at a tenth of the speed you can see exactly when. Animation needs the same: most interface motion is over in a quarter of a second, too fast to study. The Motion Timeline is your slow-motion replay.

Words you'll meet

New words in this topic, in plain English. Come back here whenever one feels fuzzy.

Motion Timeline
The panel under every live example on this course: it pauses, slows, steps and scrubs the page, and shows each animation as a track.
track
One row on the timeline: one animation, with when it starts, how long it lasts and what it changes.
keyframe
A value an animation must pass through at a certain point, for example "at 40%, scale 1.5". The browser works out the frames between keyframes.
scrub
To drag through time to a chosen moment, like dragging the playhead of a video.
60 Hz
A screen that shows 60 frames a second: one frame every 16.7 milliseconds. Many phones and laptops are 90 or 120 Hz.
cost colour
The green, amber or red mark on a track: whether animating that property makes the browser only composite, also repaint, or also lay out the page.

Step by step

01Run the example and find the spinner's track

"Your first look at the timeline" below has a spinner that turns forever. Before you click anything, the timeline already shows one track: @keyframes · spin, with ∞ at its end. The console says animations at load: 1.

02Start a transition and pause it half way

Press Move the bike. A second track appears: transition · transform, 600 ms long. When it ends, its bar fades to a dimmed colour: a finished animation stays on the timeline. Press the button again to send the bike back, and press Pause while it is moving. The bike stops in mid-air, the viewfinder says PAUSED, and the spinner stops too: the whole page is frozen.

03Step frame by frame

Press Step a few times. Each press moves time on by 16.7 ms, and the bike moves a little. Near the start and end of the move each step moves it only a little; in the middle, more. That is the ease-in-out curve: slow, fast, slow. Phase 5 is all about these curves.

04Slow everything down

Press 0.1×, then Play. Now the 600 ms move takes 6 seconds. Press Flash the price: a third track, WAAPI · background-color, appears. Its cost mark is green, a surprise: current Chromium can animate a background-color on the compositor without repainting (Phase 6 shows the measured table). Change backgroundColor to color in the code and the mark turns amber: text colour repaints.

05Read a track's details

Click the transition's track. Its details show the kind (CSSTransition), duration 600 ms, delay 0, easing ease-in-out, and a graph of transform over time: an S-shaped curve. Every number you will need to reason about an animation is here.

Try it yourself

  1. 1

    Count the frames of a 600 ms move

    In "Your first look at the timeline", press Pause, then Move the bike, then press Step until the bike stops moving. At 60 frames a second, 600 ms is 36 frames: watch the frame counter (F 0036 more than where you started) when it arrives. On a 120 Hz screen the same move has 72 frames, each one smaller. Phase 1 explains why the time stays the same.

  2. 2

    Change the duration and see the track change

    In the CSS tab change transition: transform 600ms ease-in-out; to 1500ms. After the page runs again, press Move the bike: the track now says 1500 ms in its details. The bar on the ruler is longer too, but not exactly two and a half times: the ruler rescales itself (its end moves out, and its tick labels change) so the whole animation fits.

  3. 3

    Spot the layout cost

    In "Two ways to grow a bar", look at the timeline before you press anything: it says nothing is moving yet (an empty timeline is normal until something animates). Now press the button. Two tracks appear: transition · width with a red mark, and transition · transform with a green one, plus a costs layout badge. They look the same on a fast computer. On a cheap phone the red one is the one that stutters, because the browser must lay out the page 60 times a second.

Code & diagrams

Your first look at the timeline

Three kinds of animation on one page: a CSS keyframe animation that never ends, a CSS transition, and a Web Animations API animation. Pause, step and slow it down using the transport under the viewfinder.

Press Run to see the page.
00:00.000
animations
0.00s0.10s0.20s0.30s0.40s0.50s0.60s0.70s0.80s0.90s

Nothing is moving yet. Hover, click or scroll the page: every animation it starts shows up here as a track.

frames

Console

Nothing logged yet.

Expected console output

animations at load: 1
Two ways to grow a bar

Both bars grow over 1 second with the same easing and look almost the same. Press the button and look at the cost marks: width is red (layout every frame), transform is green (composite only).

Press Run to see the page.
00:00.000
animations
0.00s0.10s0.20s0.30s0.40s0.50s0.60s0.70s0.80s0.90s

Nothing is moving yet. Hover, click or scroll the page: every animation it starts shows up here as a track.

frames

Console

Nothing logged yet.

Break it on purpose

Errors are the best teachers. Make each change, read the error, guess what went wrong, then reveal the answer.

Break #1

Animate the bike with left instead of transform

In "Your first look at the timeline", change the CSS to #bike { position: relative; left: 0; width: 40px; font-size: 28px; transition: left 600ms ease-in-out; } #bike.far { left: 200px; } and press Move the bike.

terminal
$ Press "Move the bike" and read the track
── what you'll see ──
The bike moves the same way, but the track says transition · left with a red mark, and the "costs layout" badge appears.

Myth vs fact

Myth

If an animation looks smooth on my laptop, it is fine.

Fact

Your laptop is probably much faster than many of your users' phones. Check the cost marks and the frame strip here, and Phase 6 shows how to slow your computer down in DevTools to see what a cheap phone sees.

Pro corner

Extra depth for experienced readers. New to this? Skip it for now and come back later.

  • ▸

    The timeline drives a page with one virtual clock. When you pause or slow down, performance.now(), Date.now(), requestAnimationFrame times and timers all follow it, and CSS and Web Animations API animations are held and moved to that time each frame. That is why GSAP, Motion and your own loops pause together.

  • ▸

    While the timeline controls the page, CSS animations are moved by the main thread, so for performance experiments (Phase 6) use Replay and full speed, or your browser's DevTools, which measure the page as it really runs.

  • ▸

    The value graph samples the animation's real computed value at 61 points by seeking it, so it shows the true curve, including the browser's own interpolation of transform matrices and colours.

Remember this

  1. 1

    The problem this solves: when an animation looks wrong you usually cannot say why, because it is over before you can look. Is it too slow at the start? Does it jump at the end? Is the browser struggling? You need to stop time, step through it and see the numbers.

  2. 2

    The editor and the viewfinder. Edit the code (HTML, CSS, JavaScript tabs) and the page runs again by itself after a short pause, or press Run (Ctrl+Enter). The page appears in the viewfinder, with LIVE or PAUSED in its corner. Reset puts the example back as it was. Your edits are kept in this browser, so you can leave and come back.

  3. 3

    The transport. Replay runs the page again from the start. Pause freezes everything that moves on the page: CSS animations and transitions, JavaScript loops, timers, and library animations from GSAP or Motion. Step moves time forward by one frame (16.7 ms, one frame on a 60 Hz screen). The speed buttons 0.1×, 0.25×, 0.5×, 1× slow the whole page down. The time shows as minutes:seconds.milliseconds, with the frame number next to it.

  4. 4

    Tracks. Each animation on the page becomes a row. The label says which element and what kind (transition, @keyframes, WAAPI, GSAP), then what it changes: the CSS property for a transition or a WAAPI animation (transition · transform, WAAPI · background-color), the animation's name for a CSS keyframe animation (@keyframes · spin). The bar shows when it starts, how long it lasts (a hatched part is its delay), and small diamonds mark its keyframes (the values it passes through). An infinite animation runs off the end with ∞, and an animation that has ended stays as a dimmed bar. With nothing moving yet, the timeline says so instead of showing an empty ruler. Click a track to see its details (including its easing; for a CSS keyframe animation that is the easing between keyframes) and a graph of the value over time.

  5. 5

    Cost colours. The coloured mark at the start of a row says how much work the animation costs the browser each frame: green for composite only (it moves or blends pixels it already has: transform and opacity, and, measured in headless Chromium, also background-color and clip-path), amber for paint (it draws pixels again: text colour, borders, shadows), red for layout (it works out sizes and positions again: width, top). A costs layout badge appears when any track is red. Phase 6 explains and measures all three.

  6. 6

    Scrubbing, reduced motion and frames. Drag along the ruler to jump to a moment; dragging backwards runs the page again, frozen, and steps to that time. The ruler also works from the keyboard: focus it, then Left and Right arrows move one frame (with Shift, 100 ms) and Space pauses or plays. The Reduced motion switch runs the page as someone whose system asks for less motion. The strip at the bottom shows how long each recent frame took: green bars are on time, amber and red ones were late.

Explain it without notes

01

Why is it hard to judge an animation at full speed, and how does stepping help?

02

What do the green, amber and red cost marks mean?

Practice

01

In "Your first look at the timeline", change the spinner's 1.2s to 3s and its timing to ease-in-out. What changes on its track, and how does it look?

02

Add a fourth animation to the same example: make the price grow to 1.2 times its size and back when flashed, using a second animate() call. What does its track show?

Done when you can

  • You can pause, slow down, step and scrub a live example

  • You can read a track: kind, element, property, duration, delay, keyframes

  • You can say what each cost colour means

  • You can run an example as a reduced-motion user