@joyfulljs/dragsort
v1.0.2
Published
drag to sort
Downloads
2
Readme
dragsort
drag to sort. support both pc and mobile
installation
npm install @joyfulljs/dragsort
usage
import DragItem, { DragHandle } from '@joyfulljs/dragsort';
import '@joyfulljs/dragsort/src/index.css';
// ...
handeSortChange = (list) => {
this.setState({ list });
};
render() {
const { list } = this.state;
return (
<div>
{list.map((item, index) => {
return (
<DragItem key={index} items={list} onChange={this.handeSortChange}>
{item.label}
{/* use default drag handle */ }
<DragHandle />
{/* customize drag handle
<DragHandle>Drag Me</DragHandle>
*/}
</DragItem>
);
})}
</div>
);
}
// ...
note
- It will use
DragItem
as the drag handle whenDragHandle
is omitted
licese
MIT@elvinzhu