You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[UMD version of react-draggable](dist/react-draggable.js) is available. It is updated per-release only.
20
+
This bundle is also what is loaded when installing from npm. It expects external `React` and `ReactDOM`.
20
21
21
22
If you want a UMD version of the latest `master` revision, you can generate it yourself from master by cloning this
22
23
repository and running `$ make`. This will create umd dist files in the `dist/` folder.
23
24
24
-
## Details
25
+
## Draggable
25
26
26
27
A `<Draggable>` element wraps an existing element and extends it with new event handlers and styles.
27
28
It does not create a wrapper element in the DOM.
@@ -32,41 +33,83 @@ positioning (relative, absolute, or static). Elements can also be moved between
32
33
If the item you are dragging already has a CSS Transform applied, it will be overwritten by `<Draggable>`. Use
33
34
an intermediate wrapper (`<Draggable><span>...</span></Draggable>`) in this case.
34
35
35
-
## API
36
+
37
+
### Draggable API
38
+
36
39
The `<Draggable/>` component transparently adds draggable to whatever element is supplied as `this.props.children`.
37
40
**Note**: Only a single element is allowed or an Error will be thrown.
38
41
39
42
Props:
40
43
41
-
**`axis`**: determines which axis the draggable can move. Accepted values:
42
-
-`both` allows movement horizontally and vertically (default).
43
-
-`x` limits movement to horizontal axis.
44
-
-`y` limits movement to vertical axis.
45
-
46
-
**`handle`**: specifies a selector to be used as the handle that initiates drag.
47
-
48
-
**`cancel`**: specifies a selector to be used to prevent drag initialization.
49
-
50
-
**`grid`**: specifies the x and y that dragging should snap to.
51
-
52
-
**`bounds`**: specifies movement boundaries. Accepted values:
53
-
-`parent` restricts movement within the node's offsetParent (nearest node with position relative or absolute), or
54
-
- An object with `left, top, right, and bottom` properties. These indicate how far in each direction the draggable can be moved. See [example/index.html](https://github.com/mzabriskie/react-draggable/blob/master/example/index.html) for more on this.
55
-
56
-
**`start`**: specifies the `x` and `y` that the dragged item should start at. This is generally not necessary to use (you can use absolute or relative positioning of the child directly), but can be helpful for uniformity in your callbacks and with css transforms.
57
-
58
-
**`moveOnStartChange`**: if true (it defaults false), will move the element if there is a change in `start`. We set this by default to `false` because it can cause unwanted effects if you are not aware of it.
59
-
60
-
**`zIndex`**: specifies the zIndex to use while dragging.
61
-
62
-
**`onStart`**: called when dragging starts.
44
+
```js
45
+
{
46
+
// Called when dragging starts. If `false` is returned from this method,
47
+
// dragging will cancel.
48
+
// These callbacks are called with the arity
49
+
// (event: Event,
50
+
// {
51
+
// position: {left: number, top: number},
52
+
// deltaX: number,
53
+
// deltaY: number
54
+
// }
55
+
// )
56
+
onStart:Function,
57
+
58
+
// Called while dragging.
59
+
onDrag:Function,
60
+
61
+
// Called when dragging stops.
62
+
onStop:Function,
63
+
64
+
// Called whenever the user mouses down. Called regardless of handle or
65
+
// disabled status.
66
+
onMouseDown:Function,
67
+
68
+
// Specifies the `x` and `y` that the dragged item should start at.
69
+
// This is generally not necessary to use (you can use absolute or relative
70
+
// positioning of the child directly), but can be helpful for uniformity in
71
+
// your callbacks and with css transforms.
72
+
start: {x: number, y: number},
73
+
74
+
// If true, will not call any drag handlers.
75
+
disabled: boolean,
76
+
77
+
// Specifies a selector to be used to prevent drag initialization.
78
+
// Example: '.body'
79
+
cancel: string,
80
+
81
+
// Specifies a selector to be used as the handle that initiates drag.
82
+
// Example: '.handle'
83
+
handle: string,
84
+
85
+
// Determines which axis the draggable can move. Accepted values:
86
+
// - `both` allows movement horizontally and vertically (default).
87
+
// - `x` limits movement to horizontal axis.
88
+
// - `y` limits movement to vertical axis.
89
+
axis: string,
90
+
91
+
// Specifies movement boundaries. Accepted values:
92
+
// - `parent` restricts movement within the node's offsetParent
93
+
// (nearest node with position relative or absolute), or
94
+
// - An object with `left, top, right, and bottom` properties.
95
+
// These indicate how far in each direction the draggable
0 commit comments