Skip to content

Commit

Permalink
Updating readme + example
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Desmaisons committed Nov 26, 2018
1 parent d2c1c62 commit 22b4432
Show file tree
Hide file tree
Showing 5 changed files with 1,586 additions and 1,562 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,15 @@ Draggable component should directly wrap the draggable elements, or a `transitio
<button slot="footer" @click="addPeople">Add</button>
</draggable>
```
### With header slot:
``` html
<draggable v-model="myArray" :options="{draggable:'.item'}">
<div v-for="element in myArray" :key="element.id" class="item">
{{element.name}}
</div>
<button slot="header" @click="addPeople">Add</button>
</draggable>
```
### With Vuex:
Expand Down Expand Up @@ -290,9 +298,26 @@ HTML:
- `element`: the moved element
### Slots
#### Header
Use the `header` slot to add none-draggable element inside the vuedraggable component.
Important: it should be used in conjunction with draggable option to tag draggable element.
Note that header slot will always be added before the default slot regardless its position in the template.
Ex:
``` html
<draggable v-model="myArray" :options="{draggable:'.item'}">
<div v-for="element in myArray" :key="element.id" class="item">
{{element.name}}
</div>
<button slot="header" @click="addPeople">Add</button>
</draggable>
```
#### Footer
Use the `footer` slot to add none-draggable element inside the vuedraggable component.
Important: it should be used in conjunction with draggable option to tag draggable element.
Note that footer slot will always be added after the default slot.
Note that footer slot will always be added after the default slot regardless its position in the template.
Ex:
``` html
Expand Down
3 changes: 0 additions & 3 deletions dist/vuedraggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
var rawIndexes = [].concat(_toConsumableArray(children)).map(function (elt) {
return elmFromNodes.indexOf(elt);
});
console.log(JSON.stringify(rawIndexes));
return isTransition ? rawIndexes.filter(function (ind) {
return ind !== -1;
}) : rawIndexes;
Expand Down Expand Up @@ -363,12 +362,10 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
this.emitChanges({ removed: removed });
},
onDragUpdate: function onDragUpdate(evt) {
console.log(evt.newIndex, evt.oldIndex, evt.item);
removeNode(evt.item);
insertNodeAt(evt.from, evt.item, evt.oldIndex);
var oldIndex = this.context.index;
var newIndex = this.getVmIndex(evt.newIndex);
console.log(newIndex);
this.updatePosition(oldIndex, newIndex);
var moved = { element: this.context.element, oldIndex: oldIndex, newIndex: newIndex };
this.emitChanges({ moved: moved });
Expand Down
2 changes: 1 addition & 1 deletion dist/vuedraggable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ <h2>Normal v-for</h2>
<a href="Two_Lists.html">See 2 lists example</a>
<a href="Two_Lists_Clone.html">See clone element example</a>
<a href="Two_Lists_Clone_If.html">See clone v-if element example</a>
<a href="footerslot.html">See footer slot example</a>
<a href="headerslot.html">See header slot example</a>

</div>

Expand Down

0 comments on commit 22b4432

Please sign in to comment.