0.2.0 • Published 3 years ago

react-pan-zoom-map v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

react-pan-zoom-map

Bring Figma-like pan and zoom interactions to your React app. Unlike other packages, react-pan-zoom-map works seamlessly with trackpads (scroll to pan and pinch to zoom) in addition to mice (grab to pan and wheel to zoom). Try it out for yourself...

Example

Usage

import React from "react";
import PanZoomMap from "react-pan-zoom-map";
import cheetah from "./cheetah.png";

const App: React.FC = () => {
  return (
    <PanZoomMap>
      <img src={cheetah} alt="Cheetah" />
    </PanZoomMap>
  );
};

export default App;

Installation

npm i react-pan-zoom-map

Props

NameDescriptionDefault
controlMethod'mouse' for grab to pan and wheel to zoom or 'trackpad' for scroll to pan and pinch to zoom.'mouse'
defaultTranslationThe initial translation. This will change when you grab or scroll.{x: 0, y: 0}
defaultZoomThe initial zoom. This will change when you wheel or pinch.1
isPanEnabledMakes it so that you can or can't pan.true
isZoomEnabledMakes it so that you can or can't zoom.true
panSensitivityIf you're using controlMethod='trackpad', this changes the sensitivity of your scroll to pan.1
zoomSensitivityChanges the sensitivity of wheel to zoom or pinch to zoom.1
minZoomHow far out you can zoom. If minZoom=0.1, your elements can be up to 10x smaller.0.1
maxZoomHow far in you can zoom. if maxZoom=10, your elements can be up to 10x bigger.10
onPanZoomA callback for when the map's translation or zoom changes. You'll have access to translation and zoom in the parameters of the callback.undefined
1.1.1

3 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

1.0.0

3 years ago

0.1.0

3 years ago