3.0.1 • Published 6 years ago

react-drag-n-zoom v3.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

react-drag-n-zoom

Drag and zoom your SVGs

What does it?

react-drag-n-zoom allows you to drag, zoom, expand, center your SVGs in the web.

Look at the amazing demo:

React-Drag-N-Zoom DEMO

Install

npm install react-drag-n-zoom

or over yarn:

yarn add react-drag-n-zoom

How to Use

First import it:

import Viewer from 'react-drag-n-zoom'

Add the React Component for example in the render method (taken from ./example)

render () {
  return (
    <Viewer
      ref={ref => (this.viewer = ref)} // (see below for methods)
      zoomFullOnInit={true}
      width="100"
      height="100"
      viewBox="0 0 100 100"
    >
     <circle
        cx="50"
        cy="50"
        r="40"
        stroke="black"
        stroke-width="3"
        fill="red"
      />
    </Viewer>
  )
}

Viewer accepts as children the content of SVGs. The SVG surrounding the circle Element above, will be added automatically by react-drag-n-zoom

Warning: Make sure width, height and viewBox are supplied to Viewer!

Methods

  • this.viewer.resetZoom() - resets zoom and centers SVG at scale 1
  • this.viewer.zoomIn(value = 1.2) - zooms in SVG
  • this.viewer.zoomOut(value = 0.8) - zoom out of SVG
  • this.viewer.zoomFull() - expands SVG to fill screen
  • this.viewer.zoomTo(area) - zoom to specific area area equals e.g. { top: 655, left: 570, width: 80, height: 50}

Features

  • Extensive Functions
  • Supports every SVG
  • Uses Smooth Transitions
  • Cross-Browser Compatibility - e.g. Firefox & Chrome differ in how they implement SVGs. That's why, react-drag-n-zoom will differ them too and apply the right methods for the specific browser.
3.0.1

6 years ago

3.0.0

6 years ago

2.8.0

6 years ago

2.7.0

6 years ago

2.6.0

6 years ago

2.5.0

6 years ago

2.4.0

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.91

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago