1.2.1 • Published 6 years ago

react-free-viewport v1.2.1

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

A drag and zoom supported viewport.

Using CSS transform.

Installation

npm install --save react-free-viewport

Usage

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"));
#view-port{
    font-size: 24pt;
    padding: 20px;
    width: 400px;
    height: 300px;
    overflow: hidden;
}

DEMO

npm.io

Documentation

Props

NameTypeDefaultDescription
buttonnumber0Indicate which mouse button can be used to drag. 0: left, 1: mid, 2: right
scaleFactornumber1.2The 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.
grabCursorstring"-webkit-grabbing"The CSS cursor property value while dragging.