2.4.6 • Published 1 year ago

@sp1985/react-zoom-pan-pinch v2.4.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@pronestor/react-zoom-pan-pinch

Super fast and light react Node.js package for zooming, panning and pinching html elements in an easy way.

This is a fork of react-zoom-pan-pinch originally created in order to fix the issue with build errors because of missing source files.

Documentation

Storybook for @pronestor/react-zoom-pan-pinch.

Quick Start

Installation

yarn add @pronestor/react-zoom-pan-pinch

or

npm install @pronestor/react-zoom-pan-pinch

Usage

Basic usage:

import {
  TransformComponent,
  TransformWrapper,
} from "@pronestor/react-zoom-pan-pinch";

export const SimpleExample = () => (
  <TransformWrapper>
    <TransformComponent>
      <img src="image.jpg" alt="test" />
    </TransformComponent>
  </TransformWrapper>
);

With controls:

import {
  TransformComponent,
  TransformWrapper,
} from "@pronestor/react-zoom-pan-pinch";

export const ExampleWithZoomControls = () => (
  <TransformWrapper
    initialPositionX={200}
    initialPositionY={100}
    initialScale={1}
  >
    {({ zoomIn, zoomOut, ...rest }) => (
      <>
        <div className="tools">
          <button onClick={() => zoomIn()}>+</button>
          <button onClick={() => zoomOut()}>-</button>
        </div>
        <TransformComponent>
          <img src="image.jpg" alt="test" />
          <div>Example text</div>
        </TransformComponent>
      </>
    )}
  </TransformWrapper>
);

License

MIT © Pronestor