@joyfulljs/dragsort
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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 when DragHandle is omitted

licese

MIT@elvinzhu

Readme

Keywords

Package Sidebar

Install

npm i @joyfulljs/dragsort

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

9.6 kB

Total Files

9

Last publish

Collaborators

  • elvinzhu