# react-drag-listview

> drag list view and table view component for react

Latest version **2.0.0** (published 2023-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-drag-listview
pnpm add react-drag-listview
yarn add react-drag-listview
bun add react-drag-listview
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-01-10 |
| First published | 2017-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 340 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 237 |
| Author | raisezhang@hotmail.com |
| Maintainers | raisezhang |
| Keywords | react, react-component, sortable, antd, rc-table, react-drag, react-drag-table, react-drag-list |

## Links

- npm: https://www.npmjs.com/package/react-drag-listview
- Repository: https://github.com/raisezhang/react-drag-listview
- Homepage: https://github.com/raisezhang/react-drag-listview#readme
- Issues: https://github.com/raisezhang/react-drag-listview/issues
- npm.io page: https://npm.io/package/react-drag-listview

## Dependencies (2)

- [prop-types](https://npm.io/package/prop-types.md) ^15.5.8
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.26.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2023-01-10
- 0.2.2 — 2023-01-10
- 0.2.1 — 2022-06-04
- 0.2.0 — 2022-04-28
- 0.1.9 — 2022-02-11
- 0.1.8 — 2021-01-02
- 0.1.7 — 2020-06-21
- 0.1.6 — 2019-08-03
- 0.1.5 — 2019-08-02
- 0.1.4 — 2019-01-14
- 0.1.3 — 2018-10-18
- 0.1.2 — 2018-10-18
- 0.1.1 — 2018-10-18
- 0.1.0 — 2018-10-18
- 0.0.9 — 2017-08-25
- … 8 more at https://npm.io/package/react-drag-listview/versions

## README

# react-drag-listview

React drag list component.

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![npm download][download-image]][download-url]

[npm-image]: http://img.shields.io/npm/v/react-drag-listview.svg?style=flat-square
[npm-url]: http://npmjs.org/package/react-drag-listview
[travis-image]: https://img.shields.io/travis/raisezhang/react-drag-listview.svg?style=flat-square
[travis-url]: https://travis-ci.org/raisezhang/react-drag-listview
[download-image]: https://img.shields.io/npm/dm/react-drag-listview.svg?style=flat-square
[download-url]: https://npmjs.org/package/react-drag-listview

## install

[![rc-table](https://nodei.co/npm/react-drag-listview.png)](https://npmjs.org/package/react-drag-listview)


## Use on mobile (touch) devices

* `react-drag-listview` already supports mobile (touch) devices, which can be easily implemented based on the [dragdroptouch](https://github.com/Bernardo-Castilho/dragdroptouch) polyfill
* Need to manually add polyfill `dragdroptouch` to your website. e.g.
  ```html
  <script id="DragDropTouch" src="https://bernardo-castilho.github.io/DragDropTouch/DragDropTouch.js"></script>
  ```
* Example: [Drag on mobile devices](https://codepen.io/raisezhang/pen/wvpVbQO)

## Example

* ###### Drag Rows
    * [Simple dragging demo](https://raisezhang.github.io/react-drag-listview/examples/simple.html)
    * [Dragging Ant-Design table](https://codepen.io/raisezhang/pen/MmjypX)
    * [Dragging Ant-Design table width expanded rows](https://codepen.io/raisezhang/pen/OrrGJL)
    * [Dragging Ant-Design transfer items](https://codepen.io/raisezhang/pen/rNdGEzN)
    * [Dragging Ant-Design Nested List Items](https://codesandbox.io/s/react-drag-listview-nested-drag-example-mdrbh?file=/src/questions.js)

* ###### Drag Columns
    * [Simple dragging columns demo](https://raisezhang.github.io/react-drag-listview/examples/dragColumn.html)
    * [Dragging Ant-Design table columns](https://codepen.io/raisezhang/pen/MoMoyz)

## Development

```bash
npm install
npm start
```

## Usage

```javascript
const ReactDragListView = require('react-drag-listview');

class Demo extends React.Component {
  constructor(props) {
    super(props);

    const data = [];
    for (let i = 1, len = 7; i < len; i++) {
      data.push({
        title: `rows${i}`
      });
    }

    this.state = {
      data
    };
  }

  render() {
    const that = this;
    const dragProps = {
      onDragEnd(fromIndex, toIndex) {
        const data = [...that.state.data];
        const item = data.splice(fromIndex, 1)[0];
        data.splice(toIndex, 0, item);
        that.setState({ data });
      },
      nodeSelector: 'li',
      handleSelector: 'a'
    };

    return (
      <ReactDragListView {...dragProps}>
        <ol>
          {this.state.data.map((item, index) => (
            <li key={index}>
              {item.title}
              <a href="#">Drag</a>
            </li>
          ))}
        </ol>
      </ReactDragListView>
    );
  }
}

```

## API

### Properties

<table class="table table-bordered table-striped">
  <thead>
    <tr>
      <th style="width: 100px;">Name</th>
      <th style="width: 50px;">Type</th>
      <th>Default</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>onDragEnd</td>
      <td>Function(fromIndex, toIndex)</td>
      <td></td>
      <td>on drag end callback, required</td>
    </tr>
    <tr>
      <td>nodeSelector</td>
      <td>String</td>
      <td>tr</td>
      <td>get drag item cssQuery</td>
    </tr>
    <tr>
      <td>handleSelector</td>
      <td>String</td>
      <td><b>nodeSelector</b></td>
      <td>get drag handle cssQuery</td>
    </tr>
    <tr>
      <td>ignoreSelector</td>
      <td>String</td>
      <td></td>
      <td>ignore node list</td>
    </tr>
    <tr>
      <td>enableScroll</td>
      <td>Boolean</td>
      <td>true</td>
      <td>whether use auto scroll for dragging</td>
    </tr>
    <tr>
      <td>scrollSpeed</td>
      <td>Number</td>
      <td>10</td>
      <td>scroll speed</td>
    </tr>
    <tr>
      <td>lineClassName</td>
      <td>String</td>
      <td></td>
      <td>get dragLine's className, css properties must be use <b>!important</b></td>
    </tr>
  </tbody>
</table>

## License

react-drag-listview is released under the MIT license.

---
_Source: https://npm.io/package/react-drag-listview · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
