1 | # bee-dnd
|
2 |
|
3 | [![npm version](https://img.shields.io/npm/v/bee-dnd.svg)](https://www.npmjs.com/package/bee-dnd)
|
4 | [![Build Status](https://img.shields.io/travis/tinper-bee/bee-dnd/master.svg)](https://travis-ci.org/tinper-bee/bee-dnd)
|
5 | [![Coverage Status](https://coveralls.io/repos/github/tinper-bee/bee-dnd/badge.svg?branch=master)](https://coveralls.io/github/tinper-bee/bee-dnd?branch=master)
|
6 | [![devDependency Status](https://img.shields.io/david/dev/tinper-bee/bee-dnd.svg)](https://david-dm.org/tinper-bee/bee-dnd#info=devDependencies)
|
7 | [![NPM downloads](http://img.shields.io/npm/dm/bee-dnd.svg?style=flat)](https://npmjs.org/package/bee-dnd)
|
8 | [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/tinper-bee/bee-dnd.svg)](http://isitmaintained.com/project/tinper-bee/bee-dnd "Average time to resolve an issue")
|
9 | [![Percentage of issues still open](http://isitmaintained.com/badge/open/tinper-bee/bee-dnd.svg)](http://isitmaintained.com/project/tinper-bee/bee-dnd "Percentage of issues still open")
|
10 |
|
11 |
|
12 | react bee-dnd component for tinper-bee
|
13 |
|
14 | 基于 [react-beautiful-dnd](https://github.com/atlassian/react-beautiful-dnd) 的拖拽
|
15 |
|
16 | ## 使用方法
|
17 |
|
18 | ```
|
19 | import Dnd from 'bee-dnd';
|
20 | class Demo1 extends Component {
|
21 |
|
22 | render() {
|
23 | return (
|
24 | <div>
|
25 | <Dnd >
|
26 | <div>我可拖拽</div>
|
27 | </Dnd>
|
28 | </div>
|
29 |
|
30 | );
|
31 | }
|
32 | }
|
33 | ```
|
34 |
|
35 | #### 样式引入
|
36 | - 可以使用link引入build目录下Clipboard.css
|
37 | ```
|
38 | <link rel="stylesheet" href="./node_modules/bee-clipboard/build/Dnd.css">
|
39 | ```
|
40 | - 可以在js中import样式
|
41 | ```js
|
42 | import "./node_modules/bee-dnd/src/Dnd.scss"
|
43 | //或是
|
44 | import "./node_modules/bee-dnd/build/Dnd.css"
|
45 | ```
|
46 |
|
47 | ## 模块拖拽API
|
48 |
|
49 | |参数|说明|类型|默认值|
|
50 | |:---|:-----|:----|:------|
|
51 | |onStart|拖拽开始的钩子函数|function|-|
|
52 | |onDrag|拖拽中的钩子函数|function|-|
|
53 | |onStop|拖拽结束的钩子函数|function|-|
|
54 | |dragClass|拖拽元素的class|string|-|
|
55 | |dragingClass|拖拽中的class|string|-|
|
56 | |draggedClass|拖拽过后的class|string|-|
|
57 | |axis|设置可拖拽的方向|string|-|
|
58 | |handle|设置把手|string|-|
|
59 | |cancel|设置不可拖拽区域|string|-|
|
60 | |grid|设置每次拖拽移动的距离|array|-|
|
61 | |bounds|设置移动范围|object/string|-|
|
62 |
|
63 | ## 拖拽排序API
|
64 |
|
65 | |参数|说明|类型|默认值|
|
66 | |:---|:-----|:----|:------|
|
67 | |list|需要遍历的数组|array|[]|
|
68 | |onStart|拖拽开始的钩子函数|function|-|
|
69 | |onDragUpdate|拖拽中列表有更新时的钩子函数|function|-|
|
70 | |onStop|拖拽结束的钩子函数|function|-|
|
71 | |dropClass|拖动面板drop的class|string|-|
|
72 | |dropOverClass|拖动面板drop被经过的class|string|-|
|
73 | |dragClass|拖拽元素drag的class|string|-|
|
74 | |dragingClass|拖拽元素正在被拖拽的class|string|-|
|
75 | |type|设置拖拽列类型`vertical`单列纵向,`horizontal`单列横向,`betweenVertical`两列纵向,`betweenHorizontal`两列横向|`vertical`/`horizontal`/`betweenVertical`/`betweenHorizontal`|-|
|
76 | |otherList|`type=betweenVertical/betweenHorizontal`时需要的第二个数组|array|[]|
|
77 | |showKey|拖拽数组需要显示的`key`值,如 示例8|string|-|
|
78 |
|
79 |
|
80 | ## 拖拽排序回调函数参数说明
|
81 |
|
82 | ### 第一个参数 result
|
83 |
|
84 | - `destination` Draggable完成的位置。如果用户在不超过Droppable的情况下掉落,则目标将为空
|
85 | - `draggableId` 被拖动的Draggable的ID
|
86 | - `source` Draggable开始的位置
|
87 |
|
88 | ### 第二个参数
|
89 |
|
90 | - 单个数组为单列排序后的数组
|
91 | - 对象为两列培训后的两个数组对象
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | ## 说明
|
97 |
|
98 | > 本组件提供三种使用方式,第一种:模块拖拽。第二种:拖拽排序,包括:横向排序、纵向排序、两个纵向交换、两个横向交换。第三种:更复杂的拖拽排序,可用 Dnd 组件内的 `DragDropContext, Droppable, Draggable`,并参考 [react-beautiful-dnd](https://github.com/atlassian/react-beautiful-dnd)。 如要实现更复杂的拖拽排序,可使用第三种方法
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | #### 开发调试
|
104 |
|
105 | ```sh
|
106 | $ npm install -g bee-tools
|
107 | $ git clone https://github.com/tinper-bee/bee-dnd
|
108 | $ cd bee-dnd
|
109 | $ npm install
|
110 | $ npm run dev
|
111 | ``` |
\ | No newline at end of file |