Skip to content

Commit ee30fc6

Browse files
Adding tranistion example
1 parent eb6a1ac commit ee30fc6

File tree

2 files changed

+155
-1
lines changed

2 files changed

+155
-1
lines changed

example/App.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@
6464
>Transition</a>
6565
</li>
6666

67+
<li class="nav-item">
68+
<a
69+
class="nav-link"
70+
data-toggle="tab"
71+
href="#transitions"
72+
role="tab"
73+
aria-controls="profile"
74+
aria-selected="false"
75+
>Transitions</a>
76+
</li>
77+
6778
<li class="nav-item">
6879
<a
6980
class="nav-link"
@@ -154,6 +165,15 @@
154165
>
155166
<transition-example />
156167
</div>
168+
169+
<div
170+
class="tab-pane show"
171+
id="transitions"
172+
role="tabpanel"
173+
aria-labelledby="profile-tab"
174+
>
175+
<transition-example-2 />
176+
</div>
157177
</div>
158178
</div>
159179
</div>
@@ -167,6 +187,8 @@ import footerslot from "./components/footerslot";
167187
import headerslot from "./components/headerslot";
168188
import handler from "./components/handler";
169189
import transitionExample from "./components/transition-example";
190+
import transitionExample2 from "./components/transition-example-2";
191+
170192
171193
export default {
172194
name: "app",
@@ -177,7 +199,8 @@ export default {
177199
footerslot,
178200
headerslot,
179201
handler,
180-
transitionExample
202+
transitionExample,
203+
transitionExample2
181204
}
182205
};
183206
</script>
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<template>
2+
<div class="justify-content-center jumbotron">
3+
<div class="row">
4+
5+
<div class="col-2">
6+
<button
7+
class="btn btn-secondary button"
8+
@click="sort"
9+
>To original order</button>
10+
</div>
11+
12+
<div class="col-6">
13+
<h3>Transition</h3>
14+
<draggable
15+
class="list-group"
16+
element="ul"
17+
v-model="list"
18+
:options="dragOptions"
19+
@start="drag = true"
20+
@end="drag = false"
21+
>
22+
<transition-group
23+
type="transition"
24+
:name="!drag? 'flip-list' : null"
25+
>
26+
<li
27+
class="list-group-item"
28+
v-for="element in list"
29+
:key="element.order"
30+
>
31+
<i
32+
:class="
33+
element.fixed ? 'fa fa-anchor' : 'glyphicon glyphicon-pushpin'
34+
"
35+
@click="element.fixed = !element.fixed"
36+
aria-hidden="true"
37+
></i>
38+
{{ element.name }}
39+
</li>
40+
</transition-group>
41+
</draggable>
42+
</div>
43+
44+
<rawDisplayer
45+
class="col-3"
46+
:value="list"
47+
title="List"
48+
/>
49+
50+
</div>
51+
</div>
52+
53+
</template>
54+
55+
<script>
56+
import draggable from "@/vuedraggable";
57+
import rawDisplayer from "./raw-displayer.vue";
58+
59+
const message = [
60+
"vue.draggable",
61+
"draggable",
62+
"component",
63+
"for",
64+
"vue.js 2.0",
65+
"based",
66+
"on",
67+
"Sortablejs"
68+
];
69+
70+
export default {
71+
name: "tranistion-example",
72+
components: {
73+
draggable,
74+
rawDisplayer
75+
},
76+
data() {
77+
return {
78+
list: message.map((name, index) => {
79+
return { name, order: index + 1, fixed: false };
80+
}),
81+
drag: false
82+
};
83+
},
84+
methods:{
85+
sort(){
86+
this.list = this.list.sort((a,b) => a.order - b.order);
87+
}
88+
},
89+
computed: {
90+
dragOptions() {
91+
return {
92+
animation: 200,
93+
group: "description",
94+
disabled: false,
95+
ghostClass: "ghost"
96+
};
97+
}
98+
}
99+
};
100+
</script>
101+
102+
<style>
103+
.button {
104+
margin-top: 50px;
105+
}
106+
107+
.flip-list-move {
108+
transition: transform 0.5s;
109+
}
110+
111+
.no-move {
112+
transition: transform 0s;
113+
}
114+
115+
.ghost {
116+
opacity: 0.5;
117+
background: #c8ebfb;
118+
}
119+
120+
.list-group {
121+
min-height: 20px;
122+
}
123+
124+
.list-group-item {
125+
cursor: move;
126+
}
127+
128+
.list-group-item i {
129+
cursor: pointer;
130+
}
131+
</style>

0 commit comments

Comments
 (0)