react-zoom-pan-pinch

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

Library
npm
v4.0.4
1,911stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
68/100Good
Development Activity60
Maintenance48
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture80
Code Quality78
Innovation72
Learning Curve82

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
86%
MIT

ai-toolkit

AI Development · AI Design Tools

11,757

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
77
Repo Health
66
Technical
75
Dependency
Built with
Python86%
TypeScript13%
Updated 2 days ago
TypeScript
66%
Apache 2.0

Appsmith

Developer Tools · Automation · No Code Platforms

40,707

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

View details
94
Repo Health
79
Technical
68
Dependency
Built with
TypeScript66%
Java22%
Updated today
TypeScript
92%
Other

GitNexus

Developer Tools · AI Code Assistants

45,566

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
74
Dependency
Built with
TypeScript92%
Updated today
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,083

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
62
Repo Health
81
Technical
66
Dependency
Built with
TypeScript91%
Updated 3 days ago
TypeScript
98%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

485

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
70
Dependency
Built with
TypeScript98%
Updated today
TypeScript
96%
AGPL 3.0

Midday

Invoicing Finance · Productivity

14,770

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

View details
56
Repo Health
78
Technical
72
Dependency
Built with
TypeScript96%
Updated 2 months ago
TypeScript
97%
Other

Outline

Knowledge Management · Collaboration

40,236

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

View details
91
Repo Health
87
Technical
69
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
99%
Other

Papermark

Digital Signiture · File Storage

8,952

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

View details
86
Repo Health
63
Technical
68
Dependency
Built with
TypeScript99%
Updated yesterday
TypeScript
98%
Other

Sourcebot

Search · Developer Tools · AI Code Assistants

3,892

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
86
Repo Health
83
Technical
67
Dependency
Built with
TypeScript98%
Updated today

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

Search