Skip to content

Commit 22b4432

Browse files
Updating readme + example
1 parent d2c1c62 commit 22b4432

File tree

5 files changed

+1586
-1562
lines changed

5 files changed

+1586
-1562
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,15 @@ Draggable component should directly wrap the draggable elements, or a `transitio
113113
<button slot="footer" @click="addPeople">Add</button>
114114
</draggable>
115115
```
116-
116+
### With header slot:
117+
``` html
118+
<draggable v-model="myArray" :options="{draggable:'.item'}">
119+
<div v-for="element in myArray" :key="element.id" class="item">
120+
{{element.name}}
121+
</div>
122+
<button slot="header" @click="addPeople">Add</button>
123+
</draggable>
124+
```
117125
118126
### With Vuex:
119127
@@ -290,9 +298,26 @@ HTML:
290298
- `element`: the moved element
291299
292300
### Slots
301+
302+
#### Header
303+
Use the `header` slot to add none-draggable element inside the vuedraggable component.
304+
Important: it should be used in conjunction with draggable option to tag draggable element.
305+
Note that header slot will always be added before the default slot regardless its position in the template.
306+
Ex:
307+
308+
``` html
309+
<draggable v-model="myArray" :options="{draggable:'.item'}">
310+
<div v-for="element in myArray" :key="element.id" class="item">
311+
{{element.name}}
312+
</div>
313+
<button slot="header" @click="addPeople">Add</button>
314+
</draggable>
315+
```
316+
317+
#### Footer
293318
Use the `footer` slot to add none-draggable element inside the vuedraggable component.
294319
Important: it should be used in conjunction with draggable option to tag draggable element.
295-
Note that footer slot will always be added after the default slot.
320+
Note that footer slot will always be added after the default slot regardless its position in the template.
296321
Ex:
297322
298323
``` html

dist/vuedraggable.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
5151
var rawIndexes = [].concat(_toConsumableArray(children)).map(function (elt) {
5252
return elmFromNodes.indexOf(elt);
5353
});
54-
console.log(JSON.stringify(rawIndexes));
5554
return isTransition ? rawIndexes.filter(function (ind) {
5655
return ind !== -1;
5756
}) : rawIndexes;
@@ -363,12 +362,10 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
363362
this.emitChanges({ removed: removed });
364363
},
365364
onDragUpdate: function onDragUpdate(evt) {
366-
console.log(evt.newIndex, evt.oldIndex, evt.item);
367365
removeNode(evt.item);
368366
insertNodeAt(evt.from, evt.item, evt.oldIndex);
369367
var oldIndex = this.context.index;
370368
var newIndex = this.getVmIndex(evt.newIndex);
371-
console.log(newIndex);
372369
this.updatePosition(oldIndex, newIndex);
373370
var moved = { element: this.context.element, oldIndex: oldIndex, newIndex: newIndex };
374371
this.emitChanges({ moved: moved });

dist/vuedraggable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ <h2>Normal v-for</h2>
3636
<a href="Two_Lists.html">See 2 lists example</a>
3737
<a href="Two_Lists_Clone.html">See clone element example</a>
3838
<a href="Two_Lists_Clone_If.html">See clone v-if element example</a>
39+
<a href="footerslot.html">See footer slot example</a>
40+
<a href="headerslot.html">See header slot example</a>
3941

4042
</div>
4143

0 commit comments

Comments
 (0)