# react-free-viewport

> A viewport with drag and zoom support.

Latest version **1.2.1** (published 2018-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-free-viewport
pnpm add react-free-viewport
yarn add react-free-viewport
bun add react-free-viewport
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2018-09-20 |
| First published | 2018-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 15.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | SardineFish |
| Maintainers | sardinefish |
| Keywords | react, viewport, scale, drag, move, zoom |

## Links

- npm: https://www.npmjs.com/package/react-free-viewport
- Repository: https://github.com/SardineFish/react-free-viewport
- Homepage: https://github.com/SardineFish/react-free-viewport#readme
- Issues: https://github.com/SardineFish/react-free-viewport/issues
- npm.io page: https://npm.io/package/react-free-viewport

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^16.5.2
- [@types/react](https://npm.io/package/@types/react.md) ^16.4.14

## 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

- 1.2.1 (latest) — 2018-09-20
- 1.2.0 — 2018-09-20
- 1.1.0 — 2018-09-20
- 1.0.1 — 2018-09-19
- 1.0.0 — 2018-09-19

## README

A drag and zoom supported viewport. 

Using CSS transform. 

## Installation

```shell
npm install --save react-free-viewport
```

## Usage

```jsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import ViewPort from "react-free-viewport";

const element = (
    <div>
        <ViewPort id="view-port">
            <div>
                Hello World!
            </div>
        </ViewPort>
    </div>
);
const $ = selector => document.querySelector(selector);

ReactDOM.render(element, $("#root"));
```

```css
#view-port{
    font-size: 24pt;
    padding: 20px;
    width: 400px;
    height: 300px;
    overflow: hidden;
}
```

**DEMO**

![](https://cdn-img.sardinefish.com/NTk5NDM5)


## Documentation

### Props
| Name          | Type      | Default   | Description   |
| ------------- | --------- | --------- | ------------- |
| button        | number    | `0`       | Indicate which mouse button can be used to drag. `0`: left, `1`: mid, `2`: right
| scaleFactor   | number    | `1.2`     | The scale factor when the mouse wheel scroll up. If the value is less then 1, the viewport will zoom out when scroll up, and zoom in when scroll down.
| grabCursor    | string    | `"-webkit-grabbing"`  | The CSS cursor property value while dragging.

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