New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-svg-pan-zoom

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-svg-pan-zoom

A React component that adds pan and zoom features to SVG

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
79K
increased by2.81%
Maintainers
1
Weekly downloads
 
Created
Source

react-svg-pan-zoom

A react component that adds pan and zoom features to SVG

Installation

npm install --save react-svg-pan-zoom

Usage

SVGPanZoom Viewer

import React from 'react';
import ReactDOM from 'react-dom';
import {Viewer, ViewerHelper, TOOL_NONE, TOOL_PAN, TOOL_ZOOM} from 'react-svg-pan-zoom';

class MyComponent extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      value: ViewerHelper.getDefaultValue(),
      tool: TOOL_PAN      //you can change this state with TOOL_NONE or TOOL_ZOOM
    };
  }

  handleChange(event) {
    this.setState({value: event.value});
  }

  render() {
    return (
      <div>
        <Viewer viewerWidth={400} viewerHeight={400} artboardWidth={800} artboardHeight={800}
          value={this.state.value} onChange={event => this.handleChange(event)}
          tool={this.state.tool}>

          <rect x="30" y="50" width="100" height="70" fill="black"/>
          <circle cx="210" cy="120" r="50" fill="blue"/>

        </Viewer>
      </div>
    );
  }
}

Concepts

  • viewer - <div> that contains a part of drawing
  • artboard - canvas that contains the drawing

Props

  • viewerWidthrequired – width of the viewer displayed on screen
  • viewerHeightrequired – height of the viewer displayed on screen
  • viewerBackground – background of the viewer
  • artboardWidthrequired – width of the artboard (size of the original vector image)
  • artboardHeightrequired – height of the artboard (size of the original vector image)
  • artboardBackground - background of the artboard
  • value - value of the viewer (current point of view)
  • style - CSS style of the SVG tag
  • onChange - handler something changed
  • onClick - handler click
  • onMouseMove - handler mousemove
  • tool - current active tool (TOOL_NONE, TOOL_PAN, TOOL_ZOOM)

Keywords

FAQs

Package last updated on 23 May 2016

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