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

react-easy-panzoom

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-easy-panzoom

Wrapper to enable pan and zoom for any React component

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.5K
increased by59%
Maintainers
1
Weekly downloads
 
Created
Source

react-easy-panzoom

🚧 Please be advised that this library is currently under construction and might change quickly 🚧

Wrapper to enable pan and zoom features for any React component

Installation

react-panzoom requires React 16 or later.

Using npm:

npm install --save react-easy-panzoom

Using yarn:

yarn add react-easy-panzoom

Usage

import { PanZoom } from 'react-easy-panzoom'

// ...
render() {
  return (
    <PanZoom>
      { 'This content can be panned and zoomed' }
    </PanZoom>
  )
}

Key mapping

PanZoom component natively supports keyboard interactions with arrow keys and - / + keys. This mapping can be extends using keyMapping props.

e.g. Mapping w, a, s, d:

import { PanZoom } from 'react-easy-panzoom'

// ...
render() {
  return (
    <PanZoom
      keyMapping={{
        '87': { x: 0, y: -1, z: 0 },
        '83': { x: 0, y: 1, z: 0 },
        '65': { x: -1, y: 0, z: 0 },
        '68': { x: 1, y: 0, z: 0 },
      }}
    >
      { 'This content can be panned and zoomed' }
    </PanZoom>
  )
}

Properties

NameTypeDefaultDescription
autoCenterboolfalseAuto-center the view when mounting
autoCenterZoomLevelnumberSpecify the initial zoom level for auto-center
zoomSpeednumber1Sets the zoom speed
doubleZoomSpeednumber1.75Sets the zoom speed for double click
disabledboolfalseDisable pan and zoom
disableKeyInteractionboolfalseDisable keyboard interaction
realPinchboolfalseEnable real pinch interaction for touch events
keyMappingobjectfalseDefine specific key mapping for keyboard interaction (e.g. { '<keyCode>': { x: 0, y: 1, z: 0 } }, with <keyCode> being the key code to map)
onPanStartfuncFired on pan start
onPanfuncFired on pan
onPanEndfuncFired on pan end
styleobjectOverride the inline-styles of the root element

Thanks

This react library is based on the awesome panzoom by @anvaka.

License

The files included in this repository are licensed under the MIT license.

Keywords

FAQs

Package last updated on 20 Mar 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