react-zoom-pan-pinch vs react-svg-pan-zoom
Choosing SVG viewport controls or general React content transforms
react-zoom-pan-pinchreact-svg-pan-zoomSimilar Packages:

Choosing SVG viewport controls or general React content transforms

React-svg-pan-zoom focuses on navigating an SVG viewport. React-zoom-pan-pinch wraps more general content in a transformable area.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
react-zoom-pan-pinch4,146,4541,9621.2 MB223 months agoMIT
react-svg-pan-zoom25,8926951.02 MB412 years agoMIT

Content model

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.

State and controls

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.

Integration decisions

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.

How to Choose: react-zoom-pan-pinch vs react-svg-pan-zoom

  • react-zoom-pan-pinch:

    Choose pan, zoom and pinch interaction around images or other content, with custom controls built through its wrapper API.

  • react-svg-pan-zoom:

    Choose SVG-focused viewing with controlled or uncontrolled state and built-in viewer controls.

README for react-zoom-pan-pinch

react-zoom-pan-pinch

Super fast and light react npm package for zooming, panning and pinching html elements in easy way

Twitter Follow

Join our Discord community

๐Ÿข Using this library in production?

If your application depends on react-zoom-pan-pinch, I offer paid support to help you resolve issues quickly and avoid blocking releases.

Sources

Premium sponsor banner

Premium sponsor banner

Key Features

  • ๐Ÿš€ Fast and easy to use
  • ๐Ÿญ Light, without external dependencies
  • ๐Ÿ’Ž Mobile gestures, touchpad gestures and desktop mouse events support
  • ๐ŸŽ Powerful context usage, which gives you a lot of freedom
  • ๐Ÿ”ง Highly customizable
  • ๐Ÿ‘‘ Animations and Utils to create own tools
  • ๐Ÿ”ฎ Advanced hooks and components

Try other BetterTyped projects

Do you like this library? Here is what else I build and maintain.

Build your SaaS on Hype Stack

Connect any API with Hyper Fetch


Installation

npm install --save react-zoom-pan-pinch
or
yarn add react-zoom-pan-pinch

Premium sponsor banner

Premium sponsor banner

Examples

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>
  );
};

Premium sponsor banner

Premium sponsor banner

Help me keep working on this project โค๏ธ

๐Ÿ’– Our sponsors

My Sponsors

๐Ÿข Commercial Support

If you're using this library in production, I offer paid support:

  • Priority issue resolution
  • Help with debugging production issues
  • Direct contact with the maintainer

Plans start at $400/month.

๐Ÿ“ฉ Contact: [email protected]

License

MIT ยฉ prc5