File tree Expand file tree Collapse file tree 2 files changed +45
-9
lines changed
Expand file tree Collapse file tree 2 files changed +45
-9
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 22var 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 ) ;
You can’t perform that action at this time.
0 commit comments