-
Notifications
You must be signed in to change notification settings - Fork 545
/
Copy pathtransition-example.vue
115 lines (104 loc) · 2.03 KB
/
transition-example.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<template>
<div class="row">
<div class="col-2">
<button class="btn btn-secondary button" @click="sort">
To original order
</button>
</div>
<div class="col-6">
<h3>Transition</h3>
<draggable
class="list-group"
item-key="order"
tag="transition-group"
:component-data="{ tag: 'ul', name: 'flip-list', type: 'transition' }"
v-model="list"
v-bind="dragOptions"
@start="isDragging = true"
@end="isDragging = false"
>
<template #item="{ element }">
<li class="list-group-item">
<i
:class="
element.fixed ? 'fa fa-anchor' : 'glyphicon glyphicon-pushpin'
"
@click="element.fixed = !element.fixed"
aria-hidden="true"
></i>
{{ element.name }}
</li>
</template>
</draggable>
</div>
<rawDisplayer class="col-3" :value="list" title="List" />
</div>
</template>
<script>
import draggable from "@/vuedraggable";
const message = [
"vue.draggable",
"draggable",
"component",
"for",
"vue.js 2.0",
"based",
"on",
"Sortablejs"
];
let order = message.length;
export default {
name: "transition-example",
display: "Transition",
order: 6,
components: {
draggable
},
data() {
return {
list: message.map((name, index) => {
return { name, order: index + 1 };
})
};
},
methods: {
sort() {
this.list = this.list.sort((a, b) => a.order - b.order);
}
},
computed: {
dragOptions() {
return {
animation: 0,
group: "description",
disabled: false,
ghostClass: "ghost"
};
}
}
};
</script>
<style>
.button {
margin-top: 35px;
}
.flip-list-move {
transition: transform 0.5s;
}
.no-move {
transition: transform 0s;
}
.ghost {
opacity: 0.5;
background: #c8ebfb;
}
.list-group {
min-height: 20px;
}
.list-group-item {
cursor: move;
}
.list-group-item i {
cursor: pointer;
}
</style>