8000 GitHub - jboolean/react-zoom-pan-pinch: ๐Ÿ–ผ React library to support easy zoom, pan, pinch on various html dom elements like <img> and <div>
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

๐Ÿ–ผ React library to support easy zoom, pan, pinch on various html dom elements like <img> and <div>

License

Notifications You must be signed in to change notification settings

jboolean/react-zoom-pan-pinch

ย 
ย 

Repository files navigation

๐Ÿ–ผ React Zoom Pan Pinch

@jboolean fork

This fork adds

  • Ability to separate event-receiving part from component to transform. This allows you to have e.g. an overlay inside the zoom container but is not itself zoomed.
  • zoomToPoint method to allow zooming to a specific point on the screen. Used to implement a "click to zoom" feature.

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

Twitter Follow

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? Try out other projects

8000 Hyper Fetch

โšกHyper Fetch - Fetching and realtime data exchange framework.


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="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 (
    <div className="tools">
      <button onClick={() => zoomIn()}>+</button>
      <button onClick={() => zoomOut()}>-</button>
      <button onClick={() => resetTransform()}>x</button>
    </div>
  );
};

const Example = () => {
  return (
    <TransformWrapper
      initialScale={1}
      initialPositionX={200}
      initialPositionY={100}
    >
      {({ zoomIn, zoomOut, resetTransform, ...rest }) => (
        <>
          <Controls />
          <TransformComponent>
            <img src="image.jpg" alt="test" />
            <div>Example text</div>
          </TransformComponent>
        </>
      )}
    </TransformWrapper>
  );
};

Premium sponsor banner

Premium sponsor banner

License

MIT ยฉ prc5

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

๐Ÿ’– Our sponsors

My Sponsors

About

๐Ÿ–ผ React library to support easy zoom, pan, pinch on various html dom elements like <img> and <div>

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 83.8%
  • MDX 13.9%
  • JavaScript 1.1%
  • CSS 1.1%
  • HTML 0.1%
0