Skip to content

Commit 7ac7840

Browse files
committed
Updating example
1 parent 2b17384 commit 7ac7840

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

example/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
<title>React Draggable</title>
66
<link rel="stylesheet" type="text/css" href="../lib/styles.css"/>
77
<style type="text/css">
8-
.foo {
8+
.box {
99
background: #fff;
1010
border: 1px solid #333;
1111
width: 150px;
1212
height: 150px;
13+
margin: 10px;
14+
padding: 10px;
1315
}
1416
</style>
1517
</head>

example/main.js

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,45 @@
22
var React = require('react'),
33
Draggable = require('../lib/main');
44

5-
React.renderComponent(<div>
6-
<Draggable>
7-
<div className="foo">Hello</div>
8-
</Draggable>
9-
<Draggable>
10-
<div className="foo">World</div>
11-
</Draggable>
12-
</div>, document.body);
5+
var App = React.createClass({
6+
handleStart: function (e, ui) {
7+
console.log('start');
8+
},
9+
10+
handleDrag: function (e, ui) {
11+
console.log(ui.position);
12+
},
13+
14+
handleStop: function () {
15+
console.log('stop');
16+
},
17+
18+
render: function () {
19+
return (
20+
<div>
21+
<Draggable
22+
onStart={this.handleStart}
23+
onDrag={this.handleDrag}
24+
onStop={this.handleStop}>
25+
<div className="box">I can be dragged anywhere</div>
26+
</Draggable>
27+
<Draggable
28+
axis='x'
29+
onStart={this.handleStart}
30+
onDrag={this.handleDrag}
31+
onStop={this.handleStop}>
32+
<div className="box">I can only be dragged horizonally</div>
33+
</Draggable>
34+
<Draggable
35+
axis='y'
36+
onStart={this.handleStart}
37+
onDrag={this.handleDrag}
38+
onStop={this.handleStop}>
39+
<div className="box">I can only be dragged vertically</div>
40+
</Draggable>
41+
</div>
42+
);
43+
}
44+
});
45+
46+
React.renderComponent(<App/>, document.body);

0 commit comments

Comments
 (0)