An open API service indexing awesome lists of open source software.

https://github.com/limaofeng/asany-sortable

React Sortable
https://github.com/limaofeng/asany-sortable

react react-dnd sortable

Last synced: 5 months ago
JSON representation

React Sortable

Awesome Lists containing this project

README

          

# AsanySortable

基于 React-Dnd 封装的拖拽排序组件

## Install

```bash
npm i @asany/sortable # or yarn add @asany/sortable
```

## Usage

```tsx
const defaultStyle = {
border: '1px dashed gray',
padding: '0.5rem 1rem',
marginBottom: '.5rem',
marginRight: '.5rem',
backgroundColor: 'white',
};

const SortItem = forwardRef(({ data, style, className }: SortableItemProps, ref: any) => {
return (


  • {data.name}

  • );
    }
    );

    const Example = () => {
    const [items, setItems] = useState([
    { id: '1', name: '小明', type: 'sortable-card' },
    { id: '2', name: '陈二', type: 'sortable-card' },
    { id: '3', name: '张三', type: 'sortable-card' },
    { id: '4', name: '李四', type: 'sortable-card' },
    { id: '5', name: '老五', type: 'sortable-card' },
    { id: '6', name: '赵六', type: 'sortable-card' },
    { id: '7', name: '王七', type: 'sortable-card' },
    ]);

    const handleChange = (data, event) => {
    setItems(data);
    };
    return (



    );
    };
    ```

    ## Maintainers

    [@limaofeng](https://github.com/limaofeng).

    ## License

    [MIT](LICENSE) © 李茂峰