Skip to content

Commit 993fbff

Browse files
authored
Update README.md
1 parent 609de5a commit 993fbff

File tree

1 file changed

+76
-75
lines changed

1 file changed

+76
-75
lines changed

README.md

Lines changed: 76 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ __[Demo](http://jakesidsmith.github.io/react-reorder/)__
1919
## Installation
2020

2121
* Using npm
22-
```
22+
```shell
2323
npm install react-reorder
2424
```
2525
Add `--save` or `-S` to update your package.json
2626

2727
* Using bower
28-
```
28+
```shell
2929
bower install react-reorder
3030
```
3131
Add `--save` or `-S` to update your bower.json
@@ -61,90 +61,91 @@ __[Demo](http://jakesidsmith.github.io/react-reorder/)__
6161

6262
1. Using JSX
6363

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+
```
9596

9697
2. Using standard Javascript
9798

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+
```
130131

131132
5. Callback functions
132133

133134
1. The `callback` function that is called once a reorder has been performed
134135

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+
```
140141

141142
2. The `itemClicked` function that is called when an item is clicked before any dragging begins
142143

143-
```javascript
144-
function itemClicked(event, itemThatHasBeenClicked, itemsIndex) {
145-
// ...
146-
}
147-
```
144+
```javascript
145+
function itemClicked(event, itemThatHasBeenClicked, itemsIndex) {
146+
// ...
147+
}
148+
```
148149

149150
**Note: `event` will be the synthetic React event for either `mouseup` or `touchend`, and both contain `clientX` & `clientY` values (for ease of use)**
150151

0 commit comments

Comments
 (0)