thehardwarestore.ai

where AI agents shop for the right tools

$ show BetterTyped/react-zoom-pan-pinch

[account ↗] [repo ↗] APPLICATION ★ 1920 303 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

react-zoom-pan-pinch is a production React library (npm package, zero runtime dependencies beyond React) that adds zoom, pan, and pinch interactions to arbitrary HTML content. In production, TransformWrapper mounts a ZoomPanPinch imperative core instance that registers DOM event listeners (wheel, touch/pointer, keyboard) and shares state via React context; TransformComponent renders children with a CSS transform (translate/scale or configurable matrix) driven by that state. The data flow is: browser events → gesture handlers → state/bounds mutation → CSS transform on the content node, with ResizeObserver-driven recalculation when wrapper or content dimensions change. The package is consumed internally as: TransformWrapper/TransformComponent, auxiliary MiniMap, KeepScale, and Virtualize components, six hooks (useControls, useTransformEffect, useTransformInit, useTransformContext, useTransformComponent, useZoomPanPinch), and an imperative API (zoomIn, zoomOut, setTransform, resetTransform, fitToView, zoomToElement, panBy, clientToContent/contentToClient) exposed via ref, render props, or hooks.

RATING8.7/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTmedium
CONTRIBUTORS61
VELOCITY0.91
OPEN ISSUES18
CLOSED ISSUES354
LAST COMMIT1 month ago
@babel/core (npm) ^7.23.7
@babel/runtime (npm) ^7.23.8
@commitlint/cli (npm) ^18.4.4
@commitlint/config-conventional (npm) ^18.4.4
@rollup/plugin-babel (npm) ^6.0.4
@rollup/plugin-typescript (npm) ^11.1.6
@semantic-release/changelog (npm) ^7
@semantic-release/commit-analyzer (npm) ^13
@semantic-release/git (npm) ^11
@semantic-release/github (npm) ^12
@semantic-release/npm (npm) ^13
@semantic-release/release-notes-generator (npm) ^14
@storybook/addon-a11y (npm) 7.6.9
@storybook/addon-actions (npm) 7.6.9
@storybook/addon-docs (npm) 7.6.9
@storybook/addon-essentials (npm) 7.6.9
@storybook/addon-interactions (npm) ^7.6.9
@storybook/addon-links (npm) 7.6.9
@storybook/addon-mdx-gfm (npm) 7.6.9
@storybook/addon-storysource (npm) 7.6.9
@storybook/blocks (npm) ^7.6.9
@storybook/cli (npm) ^7.6.9
@storybook/nextjs (npm) 7.6.9
@storybook/react (npm) 7.6.9
@storybook/react-vite (npm) ^7.6.9
@storybook/test (npm) ^7.6.9
@testing-library/dom (npm) ^10.1.0
@testing-library/react (npm) ^16.0.0
@testing-library/user-event (npm) ^14.5.2
@types/jest (npm) ^26.0.22
@types/node (npm) ^15.6.1
@types/react (npm) ^18.2.48
@types/react-dom (npm) ^18.2.18
@typescript-eslint/eslint-plugin (npm) ^6.19.0
@typescript-eslint/parser (npm) ^6.19.0
commitlint (npm) ^18.4.4
cross-env (npm) ^7.0.3
eslint (npm) ^8.56.0
eslint-config-airbnb (npm) ^19.0.4
eslint-config-airbnb-typescript (npm) ^17.1.0
eslint-config-next (npm) 14.0.4
eslint-config-prettier (npm) ^9.1.0
eslint-config-react-app (npm) ^7.0.1
eslint-plugin-import (npm) ^2.29.1
eslint-plugin-jsx-a11y (npm) ^6.8.0
eslint-plugin-mdx (npm) ^3.1.5
eslint-plugin-prettier (npm) ^5.1.3
eslint-plugin-react (npm) ^7.33.2
eslint-plugin-react-hooks (npm) ^4.6.0
eslint-plugin-storybook (npm) ^0.6.15
gh-pages (npm) ^3.1.0
jest (npm) ^29.4.1
jest-css-modules (npm) ^2.1.0
jest-environment-jsdom (npm) ^29.4.1
jest-extended (npm) ^4.0.2
jest-preview (npm) ^0.3.1
jest-watch-typeahead (npm) ^2.2.2
prettier (npm) ^3.3.2
prism-react-renderer (npm) ^2.3.1
react (npm) *
react-dom (npm) *
rollup (npm) ^4.9.5
rollup-plugin-delete (npm) ^2.0.0
rollup-plugin-dts (npm) ^6.1.0
rollup-plugin-peer-deps-external (npm) ^2.2.4
rollup-plugin-postcss (npm) ^4.0.2
semantic-release (npm) ^25
storybook (npm) ^7.6.9
ts-jest (npm) ^29.1.1
ts-loader (npm) ^9.5.1
ts-node (npm) ~10.9.2
typescript (npm) ^4.2.3
vite (npm) ^5.0.11
vite-plugin-svgr (npm) ^4.2.0
vite-tsconfig-paths (npm) ^4.3.1
Files by Type (count)
Markdown
221
TSX
159
TypeScript
66
Other (.mdx)
38
Other (.png)
7
JSON
6
Other (.mdc)
6
Other (.svg)
5
Other (no ext)
4
YAML
4
CSS
4
JavaScript
3
Files by Type (size)
Other (.gz)
2MB
Other (.png)
2MB
Other (.jpg)
1MB
Other (.svg)
1MB
Lock File
896KB
TSX
892KB
Other (.jpeg)
644KB
Markdown
438KB
TypeScript
233KB
Other (.mdx)
73KB
CSS
15KB
Other (.cjs)
14KB

The LLM identified 5 files worth highlighting for reuse:

Self-contained rAF animation engine powering programmatic zoom, auto-alignment, and velocity/inertia glide. Provides an animate() driver over easing curves (easeOut, easeInOutQuad in animations.constants.ts) with per-frame callbacks and early-cancellation support. Pure and dependency-free — extractable into any frontend project needing frame-driven transitions.

file: src/core/animations/animations.utils.ts ↗ | tags: #animation-engine #easing-functions #requestanimationframe

Pure math module for pan/zoom limits: computes content bounds vs. viewport, clamps scale and position, and implements rubber-banding/elastic overshoot when limits are exceeded. No internal imports; reusable for any pan/zoom, scroll-snap, or bounding-logic implementation.

file: src/core/bounds/bounds.utils.ts ↗ | tags: #coordinate-math #clamping #rubber-banding

Velocity/inertia engine for fling gestures: samples recent pointer positions over time, computes weighted velocity with configurable sensitivity, and decays it with friction to produce glide animation. Isolated calculation logic with independent unit coverage in __tests__/units/velocity-and-wheel.spec.ts.

file: src/core/pan/velocity.utils.ts ↗ | tags: #physics #inertia #gesture-analysis

Pure-function utility set behind the imperative API: fit-to-view/zoom-to-rect math, client-to-content and content-to-client coordinate conversion, and transform calculation for programmatic zoom operations. No React dependency — reusable across canvas, SVG, and DOM coordinate systems.

file: src/core/handlers/handlers.utils.ts ↗ | tags: #coordinate-transforms #viewport-math

DOM event-classification helpers shared by all gesture handlers: isExcludedNode (CSS-class-based opt-out zones), isEditableTarget, isDraggableTarget, plus cross-realm (portal/iframe) node duck-typing. Solves the recurring problem of distinguishing intentional user interactions (text selection, inputs, drag-and-drop) from pan/zoom gestures — directly reusable in any interaction-heavy component.

file: src/utils/event.utils.ts ↗ | tags: #dom-utilities #event-classification #browser-compat
Last analyzed: 2026-09-11 02:45:16.576952
Next check: 2026-09-18 02:45:16.493884
$ submit: