Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tiendeo/react-zoom-pan-pinch

Package Overview
Dependencies
Maintainers
6
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiendeo/react-zoom-pan-pinch

Zoom and pan html elements in easy way

  • 3.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
decreased by-27.27%
Maintainers
6
Weekly downloads
 
Created
Source

react-zoom-pan-pinch

NPM npm bundle size JavaScript Style Guide Package Quality NPM npm GitHub stars

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

Features

  • :rocket: Fast and easy to use
  • :factory: Light, without external dependencies
  • :gem: Mobile gestures, touchpad gestures and desktop mouse events support
  • :gift: Powerful context usage, which gives you a lot of freedom
  • :wrench: Highly customizable
  • :crown: Animations and many options

DEMO

DEMO EXAMPLE

Install

npm install --save react-zoom-pan-pinch

or

yarn add react-zoom-pan-pinch

Usage

import React, { Component } from "react";

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

class Example extends Component {
  render() {
    return (
      <TransformWrapper defaultScale={1} defaultPositionX={200} defaultPositionY={100}>
        {({ zoomIn, zoomOut, resetTransform, ...rest }) => (
          <React.Fragment>
            <div className="tools">
              <button onClick={zoomIn}>+</button>
              <button onClick={zoomOut}>-</button>
              <button onClick={resetTransform}>x</button>
            </div>
            <TransformComponent>
              <img src="image.jpg" alt="test" />
              <div>Some text</div>
            </TransformComponent>
          </React.Fragment>
        )}
      </TransformWrapper>
    );
  }
}

or

import React, { Component } from "react";

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

class Example extends Component {
  render() {
    return (
      <TransformWrapper>
        <TransformComponent>
          <img src="image.jpg" alt="test" />
        </TransformComponent>
      </TransformWrapper>
    );
  }
}

Props of TransformWrapper

PropsDefaultType
isCenteredtrueBoolean
limitToBoundstrueBoolean
limitToWrapperBoundsfalseBoolean
disabledfalseBoolean
transformEnabledtrueBoolean
positionX0Number
positionY0Number
maxPositionXnullNumber or null
minPositionXnullNumber or null
maxPositionYnullNumber or null
minPositionYnullNumber or null
zoomingEnabledtrueBoolean
scale1Number
maxScale8Number or null
minScale1Number or null
scaleAnimationPadding0.15Number
enableWheeltrueBoolean
enableTouchPadPinchtrueBoolean
wheelStep4Number
limitToWrapperOnWheelfalseBoolean
pinchEnabledtrueBoolean
pinchSensitivity1Number
panningEnabledtrueBoolean
lockAxisXfalseBoolean
lockAxisYfalseBoolean
enableVelocitytrueBoolean
velocityTimeBasedOnMovetrueBoolean
minVelocity1.6Number
minVelocityScale1Number
velocityAnimationSpeed1800Number
velocitySensitivity1Number
dbClickMode"zoomIn"String
dbClickStep40Number
zoomInStep40Number
zoomOutStep40Number
zoomInAnimationSpeed200Number
zoomOutAnimationSpeed200Number
dbClickAnimationSpeed200Number
resetAnimationSpeed200Number
paddingAnimationSpeed200Number
onWheelStartnullFunction
onWheelnullFunction
onWheelStopnullFunction
onPanningStartnullFunction
onPanningnullFunction
onPanningStopnullFunction
onPinchingStartnullFunction
onPinchingnullFunction
onPinchingStopnullFunction
onZoomChangenullFunction
enablePaddingtrueBoolean
enablePanPaddingtrueBoolean

Values returned from TransformWrapper component

ValueDescriptionType
minVelocityMinimum mouse velocity which will be animated after panning is doneNumber
minVelocityScaleVelocity will be disabled if value is equal or lower than given valueNumber
velocityTimeBasedOnMoveVelocity duration is based on the mouse move - the longer the movement, the longer the animation lastsBoolean
limitToWrapperBoundsEnables panning when zoom is lower than 1, and limit it to the wrapper boundsBoolean
limitToWrapperOnWheelZoomed object is always inside wrapper if limitBounds is activatedBoolean
limitToBoundsLimit zooming and panning to wrapper boundariesBoolean
setScale(scale)Sets scaleNumber
setPositionX(positionX)Sets position xNumber
setPositionY(positionY)Sets position yNumber
zoomIn()Zooming in function, used for controls button---
zoomOut()Zooming out function, used for controls button---
setTransform(positionX, positionY, scale)Sets transformations of contentNumber or null
resetTransform()Reset transformations to the initial valuesNumber
dbClickModeAvailable modes: "zoomIn", "zoomOut", "reset"String

License

MIT © prc5

Keywords

FAQs

Package last updated on 10 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc