Skip to content

Commit 3d8ef20

Browse files
committed
v0.1.1
1 parent 264f48d commit 3d8ef20

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Demo: http://rubaxa.github.io/Sortable/
1414
Include [react-sortable-mixin.js](react-sortable-mixin.js).
1515
See [more options](react-sortable-mixin.js#L26).
1616

17-
1817
```jsx
1918
var SortableList = React.createClass({
2019
mixins: [SortableMixin],
@@ -29,14 +28,14 @@ var SortableList = React.createClass({
2928

3029
render: function() {
3130
return <ul>{
32-
this.state.items.map(function (text) {
33-
return <li>{text}</li>
31+
this.state.items.map(function (text, i) {
32+
return <li ref={i}>{text}</li>
3433
})
3534
}</ul>
3635
}
3736
});
3837

39-
React.render(<SortableList />, document.body);
38+
ReactDOM.render(<SortableList />, document.body);
4039

4140

4241
//
@@ -52,17 +51,18 @@ var AllUsers = React.createClass({
5251
},
5352

5453
getInitialState: function() {
55-
return { users: ['Abbi', 'Adela', 'Bud', 'Cate', 'Davis', 'Eric']; };
54+
return { users: ['Abbi', 'Adela', 'Bud', 'Cate', 'Davis', 'Eric'] };
5655
},
5756

5857
render: function() {
59-
return (
60-
<h1>Users</h1>
61-
<ul ref="user">{
62-
this.state.users.map(function (text) {
63-
return <li>{text}</li>
64-
})
65-
}</ul>
58+
return (<div>
59+
<h1>Users</h1>
60+
<ul ref="user">{
61+
this.state.users.map(function (text, i) {
62+
return <li ref={i}>{text}</li>
63+
})
64+
}</ul>
65+
</div>
6666
);
6767
}
6868
});
@@ -72,19 +72,19 @@ var ApprovedUsers = React.createClass({
7272
sortableOptions: { group: "shared" },
7373

7474
getInitialState: function() {
75-
return { items: ['Hal', 'Judy']; };
75+
return { items: ['Hal', 'Judy'] };
7676
},
7777

7878
render: function() {
7979
return <ul>{
80-
this.state.items.map(function (text) {
81-
return <li>{text}</li>
80+
this.state.items.map(function (text, i) {
81+
return <li ref={i}>{text}</li>
8282
})
8383
}</ul>
8484
}
8585
});
8686

87-
React.render(<div>
87+
ReactDOM.render(<div>
8888
<AllUsers/>
8989
<hr/>
9090
<ApprovedUsers/>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-mixin-sortablejs",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "React mixin for SortableJS.",
55
"main": "react-mixin-sortable.js",
66
"scripts": {

react-mixin-sortable.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
onRemove: 'handleRemove',
3636
onSort: 'handleSort',
3737
onFilter: 'handleFilter',
38-
onMove: 'handleMove'
38+
onMove: 'handleMove',
39+
onClone: 'handleClone'
3940
};
4041

4142

@@ -70,7 +71,7 @@
7071
* @mixin
7172
*/
7273
var SortableMixin = {
73-
sortableMixinVersion: '0.1.1',
74+
sortableMixinVersion: '0.1.2',
7475

7576

7677
/**
@@ -85,8 +86,11 @@
8586
copyOptions = _extend({}, options),
8687

8788
emitEvent = function (/** string */type, /** Event */evt) {
88-
var method = this[options[type]];
89-
method && method.call(this, evt, this._sortableInstance);
89+
var method = options[type];
90+
if (method && typeof method === "string") {
91+
method = this[method];
92+
}
93+
method && typeof method === "function" && method.call(this, evt, this._sortableInstance);
9094
}.bind(this);
9195

9296

@@ -120,13 +124,13 @@
120124
}
121125

122126
newState[_getModelName(this)] = items;
123-
127+
124128
if (copyOptions.stateHandler) {
125129
this[copyOptions.stateHandler](newState);
126130
} else {
127131
this.setState(newState);
128132
}
129-
133+
130134
(this !== _activeComponent) && _activeComponent.setState(remoteState);
131135
}
132136

@@ -136,7 +140,7 @@
136140
}.bind(this);
137141
}, this);
138142

139-
DOMNode = this.getDOMNode() ? (this.refs[options.ref] || this).getDOMNode() : this.refs[options.ref] || this;
143+
DOMNode = typeof this.getDOMNode === 'function' ? (this.refs[options.ref] || this).getDOMNode() : this.refs[options.ref] || this;
140144

141145
/** @namespace this.refs — http://facebook.github.io/react/docs/more-about-refs.html */
142146
this._sortableInstance = Sortable.create(DOMNode, copyOptions);

0 commit comments

Comments
 (0)