← Downloads

zoooom

Zero-dependency pan/zoom image viewer. 25KB.

v1.2.0 0 deps ESM + CJS + IIFE
1.0x Scroll to zoom · Drag to pan · +/- keys · R to reset

Install

npm install zoooom
// Two lines. That's it.
import Zoooom from 'zoooom';
new Zoooom('#container', { src: 'image.jpg' });

Or use a script tag — no bundler needed:

<script src="https://unpkg.com/zoooom/dist/zoooom.iife.global.js"></script>
<script>new Zoooom('#el', { src: 'photo.jpg' });</script>

Features

Cursor-targeted zoom

Zooms toward the point under your cursor, not the image center. The coordinate math keeps the targeted pixel stationary at every scale.

Trackpad detection

Distinguishes trackpad from mouse wheel via delta magnitude. Continuous exponential zoom for trackpads, discrete steps for wheels.

Pinch center tracking

Two-finger zoom pivots around the actual midpoint between your fingers, recalculated each frame.

Auto max-scale

Calculates maximum zoom from the image's native resolution vs displayed size. No arbitrary limits.

Momentum

Pan release carries velocity with configurable damping. Respects prefers-reduced-motion.

Keyboard + accessibility

Arrow keys, +/-, R to reset. ARIA labels, 44px touch targets, reduced motion support.

Image preloading

Full-resolution preload with loading spinner and fade-in. Error callbacks on failure.

Joystick plugin

Optional virtual joystick with 8-direction panning, split-circle zoom, dwell activation, and screen reader support.

Input methods

MethodAction
Mouse dragPan
Scroll wheelZoom toward cursor
TrackpadContinuous zoom toward cursor
Ctrl+wheelPinch gesture (Windows/Linux)
Safari gesturesNative gesture zoom
Single touchPan
Two-finger pinchZoom with center tracking
Arrow keysPan with momentum
+/− keysZoom in/out
R keyReset view
Joystick (plugin)8-direction pan + zoom