Guide
Gestures & keys
How people move through the viewer with a mouse, a finger or a keyboard.
Gestures run on Pointer Events, the same for mouse and touch. The direction of a drag is decided once, by its first few pixels.
| Mouse | Touch | Keyboard | |
|---|---|---|---|
| Next / previous | drag sideways, arrow buttons | swipe | ← → |
| Zoom in / out | click the image, wheel, zoom button | double tap, pinch | — |
| Pan a zoomed image | drag | drag | — |
| Close | click outside, drag up or down, close button | tap outside, drag up or down | Esc |
| Move between buttons | — | — | Tab |
The feel
It comes down to a few tuned numbers:
- Opening, closing and zoom take 333 ms on
cubic-bezier(.4, 0, .22, 1). - The strip settles with a critically damped spring, starting at the velocity of your throw. A throw faster than 0.5 px/ms switches the slide even after a tiny drag; otherwise more than half of the neighbour has to be on screen.
- Swiping without a pause never loses a swipe: a flick is judged by its own direction, even while the strip is still catching up with the previous slide.
- Drag to close lags behind the finger (friction 0.6) and fades the backdrop — it's gone at a third of the screen height. It closes when the image, with its throw, would travel past 40 % of that third.
- Past the edges of the strip and of a zoomed image, movement continues with friction 0.35. The strip springs back; a thrown zoomed image glides on and bounces slightly off its edge.
- Zoom goes up to the natural size of the image, but at least 2× and at most
maxZoom. The point under the cursor or between the fingers stays in place.
Controls that step aside
With a mouse, the buttons, arrows and counter fade out when the mouse rests for 4 seconds and come back on the next move or key — the caption fades too, unless idleHidesCaption is off. Tune it with idleDelay.
On a phone
- A single tap on the image does nothing — a double tap zooms. A tap outside closes.
- The arrow buttons are hidden on touch screens (
pointer: coarse). - Lifting one finger of a pinch lets you keep panning with the other.
Reduced motion
With prefers-reduced-motion: reduce the viewer opens, closes, zooms and scrolls without animations; springs jump to their end value.