Skip to content

Commit f75fb5a

Browse files
committed
Merge pull request #53 from markthethomas/master
Move brief API documentation out of example
2 parents 0b9902f + 757e444 commit f75fb5a

File tree

1 file changed

+38
-40
lines changed

1 file changed

+38
-40
lines changed

README.md

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,41 @@ positioning (relative, absolute, or static). Elements can also be moved between
3232
If the item you are dragging already has a CSS Transform applied, it will be overwritten by `<Draggable>`. Use
3333
an intermediate wrapper (`<Draggable><span>...</span></Draggable>`) in this case.
3434

35-
## Example
35+
## API
36+
The `<Draggable/>` component transparently adds draggable to whatever element is supplied as `this.props.children`.
37+
**Note**: Only a single element is allowed or an Error will be thrown.
38+
39+
Props:
40+
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.
63+
64+
**`onDrag`**: called while dragging.
65+
66+
**`onStop`**: called when dragging stops.
67+
68+
69+
## Example usage
3670

3771
```js
3872
/** @jsx React.DOM */
@@ -57,44 +91,6 @@ var App = React.createClass({
5791

5892
render: function () {
5993
return (
60-
// <Draggable/> transparently adds draggable interactivity
61-
// to whatever element is supplied as `this.props.children`.
62-
// Only a single element is allowed or an Error will be thrown.
63-
//
64-
// The element is moved from its current position using absolute positioning.
65-
//
66-
// `axis` determines which axis the draggable can move.
67-
// - 'both' allows movement horizontally and vertically (default).
68-
// - 'x' limits movement to horizontal axis.
69-
// - 'y' limits movement to vertical axis.
70-
//
71-
// `handle` specifies a selector to be used as the handle that initiates drag.
72-
//
73-
// `cancel` specifies a selector to be used to prevent drag initialization.
74-
//
75-
// `grid` specifies the x and y that dragging should snap to.
76-
//
77-
// `bounds` specifies movement boundaries. Pass:
78-
// - 'parent' restricts movement within the node's offsetParent
79-
// (nearest node with position relative or absolute), or
80-
// - An object with left, top, right, and bottom properties. These indicate how far in each direction
81-
// the draggable can be moved. See example/index.html for more on this.
82-
//
83-
// `start` specifies the x and y that the dragged item should start at. This is generally not necessary
84-
// to use (you can use absolute or relative positioning of the child directly), but can be helpful
85-
// for uniformity in your callbacks and with css transforms.
86-
//
87-
// `moveOnStartChange`, if true (default false), will move the element if there is a change in `start`.
88-
// We set this by default to `false` because it can cause unwanted effects if you are not aware of it.
89-
//
90-
// `zIndex` specifies the zIndex to use while dragging.
91-
//
92-
// `onStart` is called when dragging starts.
93-
//
94-
// `onDrag` is called while dragging.
95-
//
96-
// `onStop` is called when dragging stops.
97-
9894
<Draggable
9995
axis="x"
10096
handle=".handle"
@@ -107,7 +103,7 @@ var App = React.createClass({
107103
onStop={this.handleStop}>
108104
<div>
109105
<div className="handle">Drag from here</div>
110-
<div>Lorem ipsum...</div>
106+
<div>This readme is really dragging on...</div>
111107
</div>
112108
</Draggable>
113109
);
@@ -117,6 +113,8 @@ var App = React.createClass({
117113
React.renderComponent(<App/>, document.body);
118114
```
119115

116+
117+
120118
## Contributing
121119

122120
- Fork the project

0 commit comments

Comments
 (0)