# react-element-pan

> React component for allowing panning of DOM-elements too large for their container, in a Google Maps-like way.

Latest version **2.0.0** (published 2018-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-element-pan
pnpm add react-element-pan
yarn add react-element-pan
bun add react-element-pan
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-07-20 |
| First published | 2014-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 171.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 60 |
| Author | Espen Hovlandsdal |
| Maintainers | rexxars |
| Keywords | react, react-component, component, scroll, pan, view, overflow |

## Links

- npm: https://www.npmjs.com/package/react-element-pan
- Repository: https://github.com/rexxars/react-element-pan
- Issues: https://github.com/rexxars/react-element-pan/issues
- npm.io page: https://npm.io/package/react-element-pan

## Dependencies (2)

- [prop-types](https://npm.io/package/prop-types.md) ^15.6.2
- [eventlistener](https://npm.io/package/eventlistener.md) 0.0.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2018-07-20
- 1.0.9 — 2017-02-17
- 1.0.8 — 2016-08-07
- 1.0.7 — 2015-12-23
- 1.0.5 — 2015-11-28
- 1.0.4 — 2015-11-14
- 1.0.3 — 2015-11-14
- 1.0.2 — 2015-01-04
- 1.0.1 — 2014-08-19
- 1.0.0 — 2014-08-19

## README

# react-element-pan

React component for allowing panning of DOM-elements too large for their container, in a Google Maps-like way. Supports touch devices and should work on IE8+.

## Demos

See [the demos page](http://rexxars.github.io/react-element-pan/) for some demos.

## Installation

`react-element-pan` can be installed using [npm](https://npmjs.org/):

```
npm install react-element-pan
```

## Basic usage

```js
const React = require('react')
const ReactDOM = require('react-dom')
const ElementPan = require('react-element-pan')

// Or, with JSX:
ReactDOM.render(
  <ElementPan
    width={800} // Optional width for the ElementPan container
    height={800} // Optional height for the ElementPan container
    startX={771} // Optional X coordinate to start at
    startY={360} // Optional Y coordinate to start at
    onPanStart={() => {
      /* Pan started! */
    }}
    onPanStop={() => {
      /* Pan ended! */
    }}
    onPan={() => {
      /* Pan move! */
    }}
  >
    <img src="some-large-image.jpg" />
  </ElementPan>,
  document.body
)
```

Note that startX/startY only works if the content is large enough when the component is mounted. You might want to set a `min-width`/`min-height` in your CSS for this to work.

### Firefox

A quick note on the firefox browser. The default behavior on `mouseDown` in firefox on images is "drag to copy". If you wish to avoid the `ghost` image, prevent default on mousedown on your image:

```js
ReactDOM.render(
  <ElementPan>
    <img src="some-large-image.jpg" onMouseDown={evt => evt.preventDefault()} />
  </ElementPan>,
  document.body
)
```

## License

Licensed under the MIT License, see LICENSE

---
_Source: https://npm.io/package/react-element-pan · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
