---
title: "Gestures & keys"
description: "How people move through the viewer with a mouse, a finger or a keyboard."
canonical_url: "https://kukson777.github.io/nuxt-image-viewer/docs/guide/gestures"
---
# 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.

<table>
<thead>
  <tr>
    <th>
      
    </th>
    
    <th>
      Mouse
    </th>
    
    <th>
      Touch
    </th>
    
    <th>
      Keyboard
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Next / previous
    </td>
    
    <td>
      drag sideways, arrow buttons
    </td>
    
    <td>
      swipe
    </td>
    
    <td>
      <kbd value="←">
        
      </kbd>
      
       <kbd value="→">
        
      </kbd>
    </td>
  </tr>
  
  <tr>
    <td>
      Zoom in / out
    </td>
    
    <td>
      click the image, wheel, zoom button
    </td>
    
    <td>
      double tap, pinch
    </td>
    
    <td>
      —
    </td>
  </tr>
  
  <tr>
    <td>
      Pan a zoomed image
    </td>
    
    <td>
      drag
    </td>
    
    <td>
      drag
    </td>
    
    <td>
      —
    </td>
  </tr>
  
  <tr>
    <td>
      Close
    </td>
    
    <td>
      click outside, drag up or down, close button
    </td>
    
    <td>
      tap outside, drag up or down
    </td>
    
    <td>
      <kbd value="Esc">
        
      </kbd>
    </td>
  </tr>
  
  <tr>
    <td>
      Move between buttons
    </td>
    
    <td>
      —
    </td>
    
    <td>
      —
    </td>
    
    <td>
      <kbd value="Tab">
        
      </kbd>
    </td>
  </tr>
</tbody>
</table>

## 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`](https://kukson777.github.io/nuxt-image-viewer/docs/customization/options#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`](https://kukson777.github.io/nuxt-image-viewer/docs/customization/options#idlehidescaption) is off. Tune it with [`idleDelay`](https://kukson777.github.io/nuxt-image-viewer/docs/customization/options#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.


## Sitemap

See the full [sitemap](https://kukson777.github.io/nuxt-image-viewer/sitemap.md) for all pages.
