Skip to content

Commit a4d178d

Browse files
committed
Release 2.0.0-alpha.1
1 parent c0ce1aa commit a4d178d

File tree

6 files changed

+11905
-1371
lines changed

6 files changed

+11905
-1371
lines changed

README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ template:
3737
</div>
3838
```
3939

40-
**NOTE** Vuejs 2.x
41-
42-
To make sure a correct update for DOM element order, we must provide a `key` for `v-for` directive inside a dragula container. https://vuejs.org/v2/guide/list.html#key
43-
With `v-for="item in list"`, we need `:key="item.id"` for object items, `:key="item"` for plain string.
44-
45-
46-
4740
## APIs
4841

4942
You can access them from `Vue.vueDragula`
@@ -63,12 +56,9 @@ new Vue({
6356
})
6457
```
6558

66-
### `find(name)`
67-
68-
Returns the `bag` for a `drake` instance. Contains the following properties:
59+
### `getDrake(name)`
6960

70-
- `name` the name that identifies the bag
71-
- `drake` the raw `drake` instance
61+
Returns the `drake` instance according the given name of a bag.
7262

7363
## Events
7464
For drake events, refer to: https://github.com/bevacqua/dragula#drakeon-events
@@ -77,7 +67,7 @@ For drake events, refer to: https://github.com/bevacqua/dragula#drakeon-events
7767
```js
7868
...
7969
new Vue({
80-
ready: function () {
70+
mounted: function () {
8171
Vue.vueDragula.eventBus.$on('drop', function (args) {
8272
console.log('drop: ' + args[0])
8373
})
@@ -88,9 +78,24 @@ new Vue({
8878

8979
## Special Events for vue-dragula
9080

91-
| Event Name | Listener Arguments | Event Description |
81+
| Event Name | Listener Arguments |
9282
| :-------------: |:-------------:| -----|
93-
| dropModel | bagName, el, target, source, dropIndex | model was synced, dropIndex exposed |
94-
| removeModel | bagName, el, container, removeIndex | model was synced, removeIndex exposed |
83+
| drop-model | bagName, el, dropTarget, dropSource, dropIndex |
84+
| remove-model | bagName, el, dropTarget, dropSource, dropIndex |
85+
86+
`dropTarget`, `dropSource`, properties:
87+
88+
- `el`: the DOM element
89+
- `model`: updated model
90+
- `expression`: the expression for directive
91+
92+
A sample function to update model on events:
93+
```js
94+
function updateModel (vm, dropTarget, dropSource) {
95+
vm[dropSource.expression] = dropSource.model
96+
if (dropTarget.el === dropSource.el) { return }
97+
vm[dropTarget.expression] = dropTarget.model
98+
}
99+
```
95100

96101
[1]: https://github.com/bevacqua/dragula

0 commit comments

Comments
 (0)