1.1.0 • Published 3 years ago

wil-react-rnd v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Wil React Rnd

Component Modal Drag & Resize For React

Installation

npm

npm install wil-react-rnd --save

yarn

yarn add wil-react-rnd

Example

https://codesandbox.io/s/wil-rnd-5n4o1

import React from "react";
import WilRnd from "wil-react-rnd";

class App extends React.Component {
  render() {
    return (
      <WilRnd
        defaultMeasure={{ width: 500, height: 300, top: 100, left: 100 }}
        widthRange={[100, 1200]}
        heightRange={[100, 1000]}
        dragHorizontalRange={[0, window.innerWidth]}
        dragVerticalRange={[0, window.innerHeight]}
        onEnd={console.log}
      >
        {({ dragRef, isStartResizable, isStartDraggable }) => (
          <div>
            <button ref={dragRef}>Drag me</button>
            Content
          </div>
        )}
      </WilRnd>
    )
  }

API

PropTypeDefaultDescription
widthRangeArray<number>[0, Infinity]min width, max width
heightRangeArray<number>[0, Infinity]min height, max height
dragHorizontalRangeArray<number>[-Infinity, Infinity]min drag horizontal, max drag horizontal
dragVerticalRangeArray<number>[-Infinity, Infinity]min drag vertical, max drag vertical
containerClassNamestring-className for component container
children({ dragRef: HTLMElement, isStartResizable: boolean, isStartDraggable: boolean }) => React.Node-dragRef example: <button ref={dragRef}>Drag me</button>, isStartResizable: when component resizing, isStartDraggable: when component dragging
onDragStart(measure: Object) => void-Callback executed when component drag start
onResizeStart(placement: string, measure: Object) => void-Callback executed when component resize start
onDrag(measure: Object) => void-Callback executed when component dragging
onResize(measure: Object) => void-Callback executed when component resizing
onEnd(measure: Object) => void-Callback executed when component drag & resize stop
onResizeDebounce(measure: Object) => void-Callback executed when component resizing ( using prop timeDebounce)
timeDebouncenumber400timeDebounce for prop onResizeDebounce
1.1.0

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago