Skip to content
IndexRequest a UIAboutContact

Pan & Zoom Viewer

Zoom a map-like image with the wheel, buttons or a two-finger pinch and drag it to pan, with zoom limits and a reset.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Clean UI mockup of an image viewer showing a detailed illustrated city map zoomed to 250 percent, the map filling a rounded frame, a small vertical stack of round buttons plus, minus and reset at the top right, a zoom percentage label at the bottom left, a thin mini-map outline in the corner showing the visible area, light neutral theme, flat modern style. Negative: heavy shadows, clutter, text errors, device frames. Reduced motion: static design.

About this pattern

Definition

A pan and zoom viewer lets people inspect detail in a large image or map. It combines three inputs: wheel or pinch to scale around the pointer, drag to move, and buttons for people who cannot use gestures. Limits stop the image being lost off screen.

Purpose & UX principles

  • Zoom around the pointer or the pinch centre, not the image corner.
  • Clamp the scale, for example one to four times, and clamp the pan so the image always covers the frame.
  • Track two pointers for pinch with pointer events; set touch-action: none.
  • Always offer plus, minus and reset buttons.

Interaction states

  • Wheel, drag, pinch and Zoom in, Zoom out and Reset buttons.

Motion specification

  • Transforms follow input directly.
  • Reduced motion: no easing is used at all.

Responsive behaviour

  • Keep the buttons outside the gesture area or clearly marked so they remain usable at any zoom.
  • Support keyboard: arrows pan, plus and minus zoom.

Code

HTML
<div class="bx"><div class="vp" id="vp" tabindex="0" aria-label="Map viewer. Arrow keys pan, plus and minus zoom."><div class="mp" id="mp"></div><span class="zl" id="zl">100%</span></div><div class="two3"><button class="mini" id="zi" type="button">Zoom in</button><button class="mini" id="zo" type="button">Zoom out</button><button class="mini" id="zr" type="button">Reset</button></div></div>

Related patterns

Lightbox Image Viewer

↗
Lightbox Image ViewerOverlays & Dialogs

Swipe Carousel

↗
Swipe CarouselGestures & Touch

Drag to Reorder

↗
Drag to ReorderGestures & Touch