1
- # Vue.Dragable.For
1
+ # Vue.Draggable
2
2
3
3
4
4
[ ![ GitHub open issues] ( https://img.shields.io/github/issues/David-Desmaisons/Vue.Dragable.For.svg?maxAge=2592000 )] ( )
9
9
[ ![ MIT License] ( https://img.shields.io/github/license/David-Desmaisons/Vue.Dragable.For.svg )] ( https://github.com/David-Desmaisons/Vue.Dragable.For/blob/master/LICENSE )
10
10
11
11
12
- Vue directive for lists allowing drag-and-drop sorting in sync with View-Model. Based on [ Sortable.js ] ( https://github.com/RubaXa/Sortable )
12
+ Vue component (Vue2.0) or directive (Vue1.0) allowing drag-and-drop and synchronization with view model array.
13
13
14
-
15
- ##Motivation
16
-
17
- Create a directive that displays a dragable list and keeps in sync the view and underlying view model.
14
+ Based on and offering all features of [ Sortable.js] ( https://github.com/RubaXa/Sortable )
18
15
19
16
##Demo
20
17
21
18
![ demo gif] ( https://raw.githubusercontent.com/David-Desmaisons/Vue.Dragable.For/master/example.gif )
22
19
23
- Simple:
24
20
25
- https://jsfiddle.net/dede89/j62g58z7/
21
+ ##Features
26
22
27
- Two Lists:
23
+ * Full support of [ Sortable.js] ( https://github.com/RubaXa/Sortable ) features
24
+ * Keeps in sync view model and view
25
+ * No jquery dependency
28
26
29
- https://jsfiddle.net/dede89/hqxranrd/
27
+ ##For Vue.js 2.0
30
28
31
- Example with list clone :
29
+ Use draggable component :
32
30
33
- https://jsfiddle.net/dede89/u5ecgtsj/
31
+ ``` html
32
+ <draggable :list =" list" :option =" {group:'people'}" @start =" dragging=true" @end =" dragging=false" >
33
+ <div v-for =" element in list" >{{element.name}}</div >
34
+ </draggable >
35
+ ```
34
36
35
- ##Features
37
+ ### Props
38
+ #### list
39
+ Type: ` Array ` <br >
40
+ Required: ` false `
41
+ Default: ` null `
36
42
37
- * Full support of [ Sortable.js] ( https://github.com/RubaXa/Sortable ) options via options parameters
38
- * Keeps in sync view model and view
39
- * No jquery dependency
43
+ Array to be synchronized with drag-and-drop. Typically same array as refrenced by inner element v-for directive.
44
+
45
+ Note that draggabe component can be used with a list prop
46
+
47
+ #### option
48
+ Type: ` Object ` <br >
49
+ Required: ` true `
50
+
51
+ Option used to inicialize the sortable object see: [ sortable option documentation] ( https://github.com/RubaXa/Sortable#options )
52
+
53
+ Note that all the method starting by "on" will be ignored as draggable component expose the same API via events.
54
+
55
+ #### Events
56
+ ` start ` , ` add ` , ` remove ` , ` update ` , ` end ` , ` choose ` , ` sort ` , ` filter ` , ` move ` , ` clone `
57
+
58
+ Called when there equivalent onStart, onAdd, .... are fired by Sortabe.js with the same argument.
59
+
60
+ [ See here for reference] ( https://github.com/RubaXa/Sortable#event-object-demo )
61
+
62
+
63
+ ##For Vue.js 1.0
40
64
41
65
##Usage
42
66
@@ -59,28 +83,41 @@ Option parameter can be json string or a full javascript object.
59
83
console .log (' Collection updated!' );
60
84
},
61
85
` ` `
86
+ ##Vue.js 1.0 fiddle
87
+
88
+ Simple:
89
+
90
+ https://jsfiddle.net/dede89/j62g58z7/
91
+
92
+ Two Lists:
93
+
94
+ https://jsfiddle.net/dede89/hqxranrd/
95
+
96
+ Example with list clone:
97
+
98
+ https://jsfiddle.net/dede89/u5ecgtsj/
62
99
63
100
## Installation
64
101
- Available through:
65
102
` ` ` js
66
- npm install vuedragablefor
103
+ npm install vuedragabble
67
104
` ` `
68
105
` ` ` js
69
- Bower install vue .dragable . for
106
+ Bower install vue .draggable
70
107
` ` `
71
108
- #### For Modules
72
109
73
110
` ` ` js
74
111
// ES6
75
112
import Vue from ' vue'
76
- import VueDragableFor from ' vuedragablefor '
77
- Vue .use (VueDragableFor )
113
+ import VueDraggable from ' vuedraggable '
114
+ Vue .use (VueDraggable )
78
115
79
116
// ES5
80
117
var Vue = require (' vue' )
81
- Vue .use (require (' vuedragablefor ' ))
118
+ Vue .use (require (' vuedraggable ' ))
82
119
` ` `
83
120
84
121
- #### For ` < script> ` Include
85
122
86
- Just include ` vue .dragable .for . js ` after Vue and lodash(version >=3).
123
+ Just include ` vuedraggable . min . js ` or ' vue.dragable.for' after Vue. lodash(version >=3) is needed only for Vuejs. 1.0 version of the library .
0 commit comments