Skip to content

Commit c2329a2

Browse files
Update example
1 parent 8064677 commit c2329a2

File tree

4 files changed

+124
-13
lines changed

4 files changed

+124
-13
lines changed

example/App.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@
4242
>Clone</a>
4343
</li>
4444

45+
<li class="nav-item">
46+
<a
47+
class="nav-link"
48+
data-toggle="tab"
49+
href="#custom-clone"
50+
role="tab"
51+
aria-controls="profile"
52+
aria-selected="false"
53+
>Custom Clone</a>
54+
</li>
55+
4556
<li class="nav-item">
4657
<a
4758
class="nav-link"
@@ -129,6 +140,15 @@
129140
<clone />
130141
</div>
131142

143+
<div
144+
class="tab-pane show"
145+
id="custom-clone"
146+
role="tabpanel"
147+
aria-labelledby="profile-tab"
148+
>
149+
<custom-clone />
150+
</div>
151+
132152
<div
133153
class="tab-pane show"
134154
id="footerslot"
@@ -182,6 +202,7 @@
182202
import simple from "./components/simple";
183203
import twoLists from "./components/two-lists";
184204
import clone from "./components/clone";
205+
import customClone from "./components/custom-clone";
185206
import footerslot from "./components/footerslot";
186207
import headerslot from "./components/headerslot";
187208
import handler from "./components/handler";
@@ -194,6 +215,7 @@ export default {
194215
simple,
195216
twoLists,
196217
clone,
218+
customClone,
197219
footerslot,
198220
headerslot,
199221
handler,

example/components/clone.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class=" justify-content-center jumbotron">
33
<div class="row">
44
<div class="col-3">
5-
<h3>Draggable for list 1</h3>
5+
<h3>Draggable 1</h3>
66
<draggable
77
class="dragArea list-group"
88
:list="list1"
@@ -14,13 +14,13 @@
1414
v-for="(element, index) in list1"
1515
:key="element.name"
1616
>
17-
{{ element.name }} {{ index }}
17+
{{ element.name }}
1818
</div>
1919
</draggable>
2020
</div>
2121

2222
<div class="col-3">
23-
<h3>Draggable for list 2</h3>
23+
<h3>Draggable 2</h3>
2424
<draggable
2525
class="dragArea list-group"
2626
:list="list2"
@@ -32,7 +32,7 @@
3232
v-for="(element, index) in list2"
3333
:key="element.name"
3434
>
35-
{{ element.name }} {{ index }}
35+
{{ element.name }}
3636
</div>
3737
</draggable>
3838
</div>

example/components/custom-clone.vue

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<template>
2+
<div class=" justify-content-center jumbotron">
3+
<div class="row">
4+
<div class="col-3">
5+
<h3>Draggable 1</h3>
6+
<draggable
7+
class="dragArea list-group"
8+
:list="list1"
9+
:options="{ group: { name: 'people', pull: 'clone', put: false} }"
10+
:clone="cloneDog"
11+
@change="log"
12+
>
13+
<div
14+
class="list-group-item"
15+
v-for="(element, index) in list1"
16+
:key="element.id"
17+
>
18+
{{ element.name }}
19+
</div>
20+
</draggable>
21+
</div>
22+
23+
<div class="col-3">
24+
<h3>Draggable 2</h3>
25+
<draggable
26+
class="dragArea list-group"
27+
:list="list2"
28+
:options="{ group: 'people' }"
29+
@change="log"
30+
>
31+
<div
32+
class="list-group-item"
33+
v-for="(element, index) in list2"
34+
:key="element.id"
35+
>
36+
{{ element.name }}
37+
</div>
38+
</draggable>
39+
</div>
40+
41+
<rawDisplayer
42+
class="col-3"
43+
:value="list1"
44+
title="List 1"
45+
/>
46+
47+
<rawDisplayer
48+
class="col-3"
49+
:value="list2"
50+
title="List 2"
51+
/>
52+
</div>
53+
</div>
54+
</template>
55+
56+
<script>
57+
import draggable from "@/vuedraggable";
58+
import rawDisplayer from "./raw-displayer.vue";
59+
let idGlobal = 8;
60+
export default {
61+
name: "clone",
62+
components: {
63+
draggable,
64+
rawDisplayer
65+
},
66+
data() {
67+
return {
68+
list1: [
69+
{ name: "dog 1", id: 1 },
70+
{ name: "dog 2", id: 2 },
71+
{ name: "dog 3", id: 3 },
72+
{ name: "dog 4", id: 4 }
73+
],
74+
list2: [
75+
{ name: "cat 5", id: 5 },
76+
{ name: "cat 6", id: 6 },
77+
{ name: "cat 7", id: 7 }
78+
]
79+
};
80+
},
81+
methods: {
82+
log: function(evt) {
83+
window.console.log(evt);
84+
},
85+
cloneDog({ id }) {
86+
return {
87+
id: idGlobal++,
88+
name: `cat ${id}`
89+
};
90+
}
91+
}
92+
};
93+
</script>
94+
<style scoped></style>

example/components/two-lists.vue

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<div class=" justify-content-center jumbotron">
33
<div class="row">
44
<div class="col-3">
5-
<h3>Draggable for list 1</h3>
5+
<h3>Draggable 1</h3>
66
<draggable
7-
class="dragArea list-group"
7+
class="list-group"
88
:list="list1"
99
:options="{ group: 'people' }"
1010
@change="log"
@@ -20,9 +20,9 @@
2020
</div>
2121

2222
<div class="col-3">
23-
<h3>Draggable for list 2</h3>
23+
<h3>Draggable 2</h3>
2424
<draggable
25-
class="dragArea list-group"
25+
class="list-group"
2626
:list="list2"
2727
:options="{ group: 'people' }"
2828
@change="log"
@@ -86,8 +86,3 @@ export default {
8686
}
8787
};
8888
</script>
89-
<style>
90-
.dragArea {
91-
min-height: 10px;
92-
}
93-
</style>

0 commit comments

Comments
 (0)