React-svg-pan-zoom focuses on navigating an SVG viewport. React-zoom-pan-pinch wraps more general content in a transformable area.
React-svg-pan-zoom is designed around an SVG viewer and its coordinate transformations. React-zoom-pan-pinch uses TransformWrapper and TransformComponent around content such as an image or a group of elements. A general transform wrapper is not automatically an SVG editing or geometry library.
React-svg-pan-zoom exposes controlled and uncontrolled viewer variants, including fit-to-view and viewer controls. React-zoom-pan-pinch offers wrapper state and helpers such as useControls for zoomIn, zoomOut and resetTransform. Keep those controls inside the wrapper context and choose which part of the interface participates in the transform.
Choose by coordinate needs, controlled state, viewport sizing and how the transformed content handles its own pointer interactions. Neither package alone supplies graph layout, image annotation persistence or a complete document editor. Broad peer ranges should not substitute for checking the APIs and rendering behavior used by the host application.
Choose pan, zoom and pinch interaction around images or other content, with custom controls built through its wrapper API.
Choose SVG-focused viewing with controlled or uncontrolled state and built-in viewer controls.
Super fast and light react npm package for zooming, panning and pinching html elements in easy way
If your application depends on react-zoom-pan-pinch, I offer paid support to help you resolve issues quickly and avoid blocking releases.
Do you like this library? Here is what else I build and maintain.
npm install --save react-zoom-pan-pinch
or
yarn add react-zoom-pan-pinch
import React, { Component } from "react";
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
const Example = () => {
return (
<TransformWrapper>
<TransformComponent>
<img src="https://raw.githubusercontent.com/BetterTyped/react-zoom-pan-pinch/HEAD/image.jpg" alt="test" />
</TransformComponent>
</TransformWrapper>
);
};
or
import {
TransformWrapper,
TransformComponent,
useControls,
} from "react-zoom-pan-pinch";
const Controls = () => {
const { zoomIn, zoomOut, resetTransform } = useControls();
return (
<div className="tools">
<button type="button" onClick={() => zoomIn()}>
+
</button>
<button type="button" onClick={() => zoomOut()}>
-
</button>
<button type="button" onClick={() => resetTransform()}>
x
</button>
</div>
);
};
const Example = () => {
return (
<TransformWrapper
initialScale={1}
initialPositionX={200}
initialPositionY={100}
>
<Controls />
<TransformComponent>
<img src="https://raw.githubusercontent.com/BetterTyped/react-zoom-pan-pinch/HEAD/image.jpg" alt="test" />
<div>Example text</div>
</TransformComponent>
</TransformWrapper>
);
};
If you're using this library in production, I offer paid support:
Plans start at $400/month.
๐ฉ Contact: [email protected]
MIT ยฉ prc5