react-zoom-pan-pinch

A React library for zooming, panning, and pinch gestures on any HTML element

Library
npm
v4.2.0
1,945 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
81 /100 Excellent
Development Activity 80
Maintenance 80
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 80
Code Quality 78
Innovation 72
Learning Curve 82

react-zoom-pan-pinch adds mouse-wheel zoom, click-and-drag panning, and touch pinch-to-zoom to any HTML element — images, divs, SVGs, or entire component trees — via a TransformWrapper/TransformComponent pair and a useTransformContext/useControls hook API. It handles the interaction math (bounds clamping, velocity-based momentum, double-tap/double-click zoom, animated transitions) that would otherwise take significant custom work to get feeling right across mouse and touch input.

It’s commonly reached for when building image viewers, diagram/canvas tools (in the vein of Figma or Miro-style pan-and-zoom canvases), and PDF or map-like viewers inside a React app, without pulling in a full canvas/graphics engine.

What You Get

  • TransformWrapper/TransformComponent components that add zoom/pan/pinch to any wrapped children with minimal setup
  • Mouse wheel zoom, click-and-drag panning, and touch pinch-to-zoom gestures out of the box
  • Programmatic control hooks (useControls, useTransformEffect) for zoom-to-point, reset, and custom UI controls
  • Bounds clamping and velocity-based momentum/animation so panning and zooming feel physically natural
  • A MiniMap component for rendering a navigable overview of the zoomed/panned content

Common Use Cases

  • Building an image viewer or gallery with pinch-to-zoom and pan on both desktop and mobile
  • Implementing a Figma/Miro-style infinite canvas or diagram editor that needs zoom and pan without a full canvas engine
  • Adding zoomable, pannable PDF page or map-style viewers to a React application
  • Giving product screenshots or technical diagrams an interactive zoom-and-pan experience in documentation sites

Under The Hood

Architecture The library is organized around a TransformWrapper context provider (src/components/transform-wrapper) that owns interaction state (scale, position, velocity) and a TransformComponent (src/components/transform-component) that applies the computed CSS transform to its children; src/core contains the gesture and calculation logic (wheel, pinch, pan handlers and bounds/velocity math in src/models/calculations.model), decoupled from the React-specific hooks in src/hooks (use-controls, use-transform-context, use-zoom-pan-pinch) that expose that core logic to consumer components, plus optional add-ons like keep-scale, mini-map, and virtualize for specialized rendering needs.

Tech Stack TypeScript, built with Rollup producing both CJS and ESM bundles, developed against a Storybook-driven component workshop (.storybook/) for visual development and documentation, tested with Jest, and released via semantic-release; React and react-dom are peer dependencies only, keeping the library framework-version-agnostic within React’s ecosystem.

Code Quality The __tests__ directory is organized by concern (features/, utils/, examples/, regressions/), with a dedicated regressions/ folder indicating the maintainer tracks and guards against previously reported bugs — a good practice signal; the docs/ directory further separates feature-requests/, bugs/, and invalid-issues/, suggesting an organized issue-triage workflow alongside the code itself.

API Design The core API — wrap content in TransformWrapper > TransformComponent — is minimal for the default case, while useControls and useTransformEffect expose an escape hatch for building custom zoom/reset buttons or reacting to transform state changes; this two-tier design (zero-config default, hooks for customization) keeps the common path simple while still supporting the diagram-editor-style use cases that need fine-grained programmatic control.

Used by 10 apps in this directory

Python
85%
MIT

ai-toolkit

AI Design Tools · AI Development

12,143

An all-in-one open-source training suite for finetuning diffusion models—FLUX, SDXL, Wan video, and audio—on consumer GPU hardware via CLI or web UI.

View details
79
Repo Health
66
Technical
72
Dependency
Built with
Python 85%
TypeScript 14%
Updated 5 days ago
TypeScript
68%
Apache 2.0

Appsmith

Automation · Developer Tools · No Code Platforms

40,959

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 68%
Java 21%
Updated 6 days ago
TypeScript
91%
Other

GitNexus

AI Code Assistants · Developer Tools · Mcp

47,620

Index any codebase into an interactive knowledge graph and give your AI agents deep architectural context via MCP — with zero servers required.

View details
88
Repo Health
86
Technical
73
Dependency
Built with
TypeScript 91%
Updated 4 days ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,182

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
70
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 2 weeks ago
TypeScript
99%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

484

Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.

View details
90
Repo Health
81
Technical
69
Dependency
Built with
TypeScript 99%
Updated 4 days ago
TypeScript
96%
AGPL 3.0

Midday

Invoicing Finance · Productivity

15,042

All-in-one AI-powered business operations platform for freelancers and solo entrepreneurs to manage invoicing, time tracking, banking, and financial intelligence.

View details
53
Repo Health
78
Technical
67
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
97%
Other

Outline

Collaboration · Knowledge Management

40,729

A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript 97%
Updated 5 days ago
TypeScript
99%
Other

Papermark

Digital Signiture · File Storage

9,218

Open-source DocSend alternative with page-by-page analytics, secure data rooms, and custom domains for document sharing.

View details
82
Repo Health
63
Technical
67
Dependency
Built with
TypeScript 99%
Updated 1 months ago
TypeScript
97%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

3,952

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
85
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers