@@ -19,13 +19,13 @@ __[Demo](http://jakesidsmith.github.io/react-reorder/)__
19
19
## Installation
20
20
21
21
* Using npm
22
- ```
22
+ ``` shell
23
23
npm install react-reorder
24
24
```
25
25
Add ` --save ` or ` -S ` to update your package.json
26
26
27
27
* Using bower
28
- ```
28
+ ``` shell
29
29
bower install react-reorder
30
30
```
31
31
Add ` --save ` or ` -S ` to update your bower.json
@@ -61,90 +61,91 @@ __[Demo](http://jakesidsmith.github.io/react-reorder/)__
61
61
62
62
1 . Using JSX
63
63
64
- ``` javascript
65
- < Reorder
66
- // The key of each object in your list to use as the element key
67
- itemKey= ' name'
68
- // Lock horizontal to have a vertical list
69
- lock= ' horizontal'
70
- // The milliseconds to hold an item for before dragging begins
71
- holdTime= ' 500'
72
- // The list to display
73
- list= {[
74
- {name: ' Item 1' },
75
- {name: ' Item 2' },
76
- {name: ' Item 3' }
77
- ]}
78
- // A template to display for each list item
79
- template= {ListItem}
80
- // Function that is called once a reorder has been performed
81
- callback= {this .callback }
82
- // Class to be applied to the outer list element
83
- listClass= ' my-list'
84
- // Class to be applied to each list item's wrapper element
85
- itemClass= ' list-item'
86
- // A function to be called if a list item is clicked (before hold time is up)
87
- itemClicked= {this .itemClicked }
88
- // The item to be selected (adds 'selected' class)
89
- selected= {this .state .selected }
90
- // The key to compare from the selected item object with each item object
91
- selectedKey= ' uuid'
92
- // Allows reordering to be disabled
93
- disableReorder= {false }/ >
94
- ```
64
+ ``` javascript
65
+ < Reorder
66
+ // The key of each object in your list to use as the element key
67
+ itemKey= ' name'
68
+ // Lock horizontal to have a vertical list
69
+ lock= ' horizontal'
70
+ // The milliseconds to hold an item for before dragging begins
71
+ holdTime= ' 500'
72
+ // The list to display
73
+ list= {[
74
+ {name: ' Item 1' },
75
+ {name: ' Item 2' },
76
+ {name: ' Item 3' }
77
+ ]}
78
+ // A template to display for each list item
79
+ template= {ListItem}
80
+ // Function that is called once a reorder has been performed
81
+ callback= {this .callback }
82
+ // Class to be applied to the outer list element
83
+ listClass= ' my-list'
84
+ // Class to be applied to each list item's wrapper element
85
+ itemClass= ' list-item'
86
+ // A function to be called if a list item is clicked (before hold time is up)
87
+ itemClicked= {this .itemClicked }
88
+ // The item to be selected (adds 'selected' class)
89
+ selected= {this .state .selected }
90
+ // The key to compare from the selected item object with each item object
91
+ selectedKey= ' uuid'
92
+ // Allows reordering to be disabled
93
+ disableReorder= {false }
94
+ / >
95
+ ```
95
96
96
97
2. Using standard Javascript
97
98
98
- ` ` ` javascript
99
- React.createElement(Reorder, {
100
- // The key of each object in your list to use as the element key
101
- itemKey: 'name',
102
- // Lock horizontal to have a vertical list
103
- lock: 'horizontal',
104
- // The milliseconds to hold an item for before dragging begins
105
- holdTime: '500',
106
- // The list to display
107
- list: [
108
- {name: 'Item 1'},
109
- {name: 'Item 2'},
110
- {name: 'Item 3'}
111
- ],
112
- // A template to display for each list item
113
- template: ListItem,
114
- // Function that is called once a reorder has been performed
115
- callback: this.callback,
116
- // Class to be applied to the outer list element
117
- listClass: 'my-list',
118
- // Class to be applied to each list item's wrapper element
119
- itemClass: 'list-item',
120
- // A function to be called if a list item is clicked (before hold time is up)
121
- itemClicked: this.itemClicked,
122
- // The item to be selected (adds 'selected' class)
123
- selected: this.state.selected,
124
- // The key to compare from the selected item object with each item object
125
- selectedKey: 'uuid',
126
- // Allows reordering to be disabled
127
- disableReorder: false
128
- })
129
- ` ` `
99
+ ` ` ` javascript
100
+ React.createElement(Reorder, {
101
+ // The key of each object in your list to use as the element key
102
+ itemKey: 'name',
103
+ // Lock horizontal to have a vertical list
104
+ lock: 'horizontal',
105
+ // The milliseconds to hold an item for before dragging begins
106
+ holdTime: '500',
107
+ // The list to display
108
+ list: [
109
+ {name: 'Item 1'},
110
+ {name: 'Item 2'},
111
+ {name: 'Item 3'}
112
+ ],
113
+ // A template to display for each list item
114
+ template: ListItem,
115
+ // Function that is called once a reorder has been performed
116
+ callback: this.callback,
117
+ // Class to be applied to the outer list element
118
+ listClass: 'my-list',
119
+ // Class to be applied to each list item's wrapper element
120
+ itemClass: 'list-item',
121
+ // A function to be called if a list item is clicked (before hold time is up)
122
+ itemClicked: this.itemClicked,
123
+ // The item to be selected (adds 'selected' class)
124
+ selected: this.state.selected,
125
+ // The key to compare from the selected item object with each item object
126
+ selectedKey: 'uuid',
127
+ // Allows reordering to be disabled
128
+ disableReorder: false
129
+ })
130
+ ` ` `
130
131
131
132
5. Callback functions
132
133
133
134
1. The ` callback` function that is called once a reorder has been performed
134
135
135
- ```javascript
136
- function callback (event , itemThatHasBeenMoved , itemsPreviousIndex , itemsNewIndex , reorderedArray ) {
137
- // ...
138
- }
139
- ```
136
+ ```javascript
137
+ function callback (event , itemThatHasBeenMoved , itemsPreviousIndex , itemsNewIndex , reorderedArray ) {
138
+ // ...
139
+ }
140
+ ```
140
141
141
142
2. The ` itemClicked` function that is called when an item is clicked before any dragging begins
142
143
143
- ```javascript
144
- function itemClicked (event , itemThatHasBeenClicked , itemsIndex ) {
145
- // ...
146
- }
147
- ```
144
+ ```javascript
145
+ function itemClicked (event , itemThatHasBeenClicked , itemsIndex ) {
146
+ // ...
147
+ }
148
+ ```
148
149
149
150
** Note: ` event` will be the synthetic React event for either ` mouseup` or ` touchend` , and both contain ` clientX` & ` clientY` values (for ease of use)**
150
151
0 commit comments