react-anything-sortable is a ReactJS component that can sort anyother component passed as this.props.children. It is compatible with IE8 and all modern browsers.
You can check the straight-forward demo by examining index.jsx, or here's a brief demo.
In your_component.jsx
var React = require('react');
var Sortable = require('react-anything-sortable/Sortable');
var YourSortableItem = require('./YourItem');
React.renderComponent(
<Sortable>
<YourItem/>
<YourItem/>
</Sortable>
, document.body);
and in YourItem.jsx
var React = require('react');
var SortableItemMixin = require('react-anything-sortable/SortableItemMixin');
var YourItem = React.createClass({
mixins: [SortableItemMixin],
render: function(){
return this.renderWithSortable(
<div>your item</div>
);
}
});
- specify your style for
SortableandSortable Items, checkstyle.css - don't forget the
this.renderWithSortablecall inYourItem.jsx - specify
sortDatainYourItem.jsxso thatSortablecan get it - add
onSortprops toSortableto be noticed when a sort operation finished - enjoy!
