react-zoom-pan-pinch
A React library for zooming, panning, and pinch gestures on any HTML element
Repository Health
Technical Analysis
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
ai-toolkit
AI Development · AI Design Tools
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.
Appsmith
Developer Tools · Automation · No Code Platforms
Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.
GitNexus
Developer Tools · AI Code Assistants
Index any codebase into an interactive knowledge graph and give your AI agents deep architectural context via MCP — with zero servers required.
Helicone
Monitoring · AI Development · Analytics
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.
GraphQL Hive
Developer Tools · Devops · Monitoring
Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.
Midday
Invoicing Finance · Productivity
All-in-one AI-powered business operations platform for freelancers and solo entrepreneurs to manage invoicing, time tracking, banking, and financial intelligence.
Outline
Knowledge Management · Collaboration
A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.
Papermark
Digital Signiture · File Storage
Open-source DocSend alternative with page-by-page analytics, secure data rooms, and custom domains for document sharing.
Sourcebot
Search · Developer Tools · AI Code Assistants
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.