Super fast and light react npm package for zooming, panning and pinching html elements in easy way
<img width="830" src="https://raw.githubusercontent.com/prc5/sponsors/main/assets/Platinum.png" alt="Premium sponsor banner"/>
<img width="830" src="https://raw.githubusercontent.com/prc5/sponsors/main/packages/platinum/sponsorkit/sponsors.svg" alt="Premium sponsor banner"/>
Do you like this library? Try out other projects
⚡Hyper Fetch - Fetching and realtime data exchange framework.
npm install --save react-zoom-pan-pinch
or
yarn add react-zoom-pan-pinch
<a href="https://github.com/sponsors/prc5?tier=Gold">
<img width="830" src="https://raw.githubusercontent.com/prc5/sponsors/main/assets/Gold.png" alt="Premium sponsor banner"/>
</a>
<a href="https://github.com/sponsors/prc5?tier=gold">
<img width="830" src="https://raw.githubusercontent.com/prc5/sponsors/main/packages/gold/sponsorkit/sponsors.svg" alt="Premium sponsor banner"/>
</a>
import React, { Component } from "react";
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
const Example = () => {
return (
<TransformWrapper>
<TransformComponent>
<img src="https://github.com/BetterTyped/react-zoom-pan-pinch/raw/v4.0.3/image.jpg" alt="test" />
</TransformComponent>
</TransformWrapper>
);
};
or
import React, { Component } from "react";
import {
TransformWrapper,
TransformComponent,
useControls,
} from "react-zoom-pan-pinch";
const Controls = () => {
const { zoomIn, zoomOut, resetTransform } = useControls();
return (
<button onClick={() => zoomIn()}>+</button>
<button onClick={() => zoomOut()}>-</button>
<button onClick={() => resetTransform()}>x</button>
);
};
const Example = () => {
return (
<TransformWrapper
initialScale={1}
initialPositionX={200}
initialPositionY={100}
>
{({ zoomIn, zoomOut, resetTransform, ...rest }) => (
<>
<Controls />
<TransformComponent>
<img src="https://github.com/BetterTyped/react-zoom-pan-pinch/raw/v4.0.3/image.jpg" alt="test" />
Example text
</TransformComponent>
</>
)}
</TransformWrapper>
);
};
<a href="https://github.com/sponsors/prc5?tier=Silver">
<img width="830" src="https://raw.githubusercontent.com/prc5/sponsors/main/assets/Silver.png" alt="Premium sponsor banner" />
</a>
<a href="https://github.com/sponsors/prc5?tier=Silver">
<img width="830" src="https://raw.githubusercontent.com/prc5/sponsors/main/packages/silver/sponsorkit/sponsors.svg" alt="Premium sponsor banner" />
</a>
MIT © prc5
<a href="https://github.com/sponsors/prc5">
<img src="https://raw.githubusercontent.com/prc5/sponsors/main/packages/other/sponsorkit/sponsors.svg?raw=true" alt="My Sponsors" />
</a>
$ claude mcp add react-zoom-pan-pinch \
-- python -m otcore.mcp_server <graph>