index.vue
2.04 KB
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
<template>
<el-card>
<div class="row">
<div class="col-6">
<draggable class="list-group" tag="ul" v-model="list" v-bind="dragOptions" @start="drag = true"
@end="drag = false">
<transition-group type="transition" :name="!drag ? 'flip-list' : null">
<li class="list-group-item" v-for="element in list" :key="element.order">
<i :class="element.fixed ? 'fa fa-anchor' : 'glyphicon glyphicon-pushpin'
" @click="element.fixed = !element.fixed" aria-hidden="true"></i>
{{ element.name }}
</li>
</transition-group>
</draggable>
</div>
</div>
</el-card>
</template>
<script>
import draggable from "vuedraggable";
const message = [
"vue.draggable",
"draggable",
"component",
"for",
"vue.js 2.0",
"based",
"on",
"Sortablejs"
];
export default {
name: "transition-example-2",
display: "Transitions",
order: 7,
components: {
draggable
},
data() {
return {
list: message.map((name, index) => {
return { name, order: index + 1 };
}),
drag: false
};
},
methods: {
sort() {
this.list = this.list.sort((a, b) => a.order - b.order);
}
},
computed: {
dragOptions() {
return {
animation: 200,
group: "description",
disabled: false,
ghostClass: "ghost"
};
}
}
};
</script>
<style lang="scss">
.el-card__body {
padding: 15px 10px 0px 10px !important;
}
.list-group {
min-height: 20px;
max-height: 150px;
overflow: auto;
margin-top: 0;
padding: 0;
&::-webkit-scrollbar {
width: 7px;
height: 7px;
}
&::-webkit-scrollbar-track {
background-color: #fff;
}
&::-webkit-scrollbar-thumb {
background-color: #ccc;
border-radius: 20px;
}
&::-webkit-scrollbar-thumb:hover {
background-color: #409eff;
}
&::-webkit-scrollbar-track-piece {
background: #F2F6FC;
}
}
.list-group-item {
cursor: move;
padding: 5px 0px;
}
.list-group-item i {
cursor: pointer;
}
</style>