8.1.2 • Published 8 months ago

react-free-draggable v8.1.2

Weekly downloads
15
License
MIT
Repository
github
Last release
8 months ago

react-free-draggable

English | 中文说明

Version

Introduction?

Using the free drag and drop component of Transform, the drag process does not affect the page layout

version8.x

  • Remove ReactDOM.findDOMNode, change to ref reference to get the dom. if children is a function component, you need to wrap it with React.forwardRef.
  • Change the parameters of onStart, onMove, onEnd callbacks
  • fixed property to resetOnEnd property to indicate whether to restore the position after the drag end
  • childProps property is deprecated
  • childProps property is deprecated
  • 8.1.0 showLayer and layerStyle deprecated.

Draggbale

  • Using tranform to realize element drag and drop movement, high performance, smooth
  • You can set the drag bounds bounds to limit the scope of the drag by setting the parent element, Full-screen drag is the default
  • Other properties of the wrapped props. children (properties that are not drag related) are not affected by react-free-draggable. It's still the same as not being wrapped
  • When set to position: absolute, you can set the x and y attributes inside the bounds element to control the position of the element

DraggableEvent

  • Provide only drag event callbacks and parameters for dragging
  • The eventBounds property can limit the extent of the event object's activity

matters

  1. children can not be inline elements, because transform does not work on inline elements!
  2. props.children is restricted to a single closing tag!
  3. x and y attributes are referenced to the bounds element.

install

npm install --save react-free-draggable
# or
yarn add react-free-draggable

example

import Draggable from 'react-free-draggable';

<div className="boxs" style={{ display: 'inline-block', width: '500px', background: "red" }}>
    <Draggable
        bounds=".boxs"
        scale={1}
        >
            <div style={{ display: "inline-block" }}>
                <div className="handle" style={{ display: "inline-block", width: "80px",background: "blue", cursor: "pointer", height: "100%" }} onClick={this.clickToast}>
                    The Dragging
                </div>
            </div>
    </Draggable>
</div>

Attributes

nametypedefaultValuedescription
handlestring / HTMLElement-Drag the class selector or element for the element
filterstring / HTMLElement-A selector or element that does not allow drag and drop
enableUserSelectHackboolean-Allows you to add selected styles
grid[number, number]-Set X, Y direction amplitude, how much to move the target
disabledboolean-disabled drag
allowAnyClickboolean-Indicates that drag is allowed without a left mouse click
onStartfunction-the start event
onMovefunction-the dragging event
onEndfunction-the end event
scalenumber1Drag sensitivity
xnumber-The position of the x-axis when the element is position: absolute.
ynumber-The position of the y-axis when the element is position: absolute.
direction['vertical','horizontal']-the direction of drag and drop
positionOffset{x: number, y: number}-Transform position increment
boundsstring / HTMLElement / {left: number, right: number, top: number, bottom: number, element: string / HTMLElement }-The range within the element, if it is element, the position is range in element, but if it is object, it is the range of the element element
resetOnEndboolean-Restore position when drag end
8.1.2

8 months ago

8.1.1

11 months ago

8.0.5

1 year ago

8.0.4

1 year ago

8.0.6

1 year ago

8.1.0

1 year ago

7.1.9

1 year ago

8.0.1

1 year ago

8.0.0

1 year ago

8.0.3

1 year ago

8.0.2

1 year ago

7.1.7

2 years ago

7.1.6

2 years ago

7.1.8

2 years ago

7.0.0

2 years ago

7.1.3

2 years ago

7.1.2

2 years ago

7.1.1

2 years ago

7.1.0

2 years ago

7.1.4

2 years ago

6.1.8

2 years ago

6.1.7

2 years ago

6.1.9

2 years ago

6.1.4

2 years ago

6.1.3

2 years ago

6.1.6

2 years ago

6.1.5

2 years ago

6.1.2

2 years ago

6.1.1

2 years ago

6.1.0

2 years ago

6.0.9

3 years ago

6.0.8

3 years ago

6.0.7

3 years ago

6.0.6

3 years ago

6.0.5

3 years ago

6.0.4

3 years ago

6.0.3

3 years ago

6.0.1

3 years ago

6.0.2

3 years ago

6.0.0

3 years ago

5.0.4

3 years ago

5.0.3

3 years ago

5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.0.0

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago