File tree Expand file tree Collapse file tree 5 files changed +182
-29
lines changed Expand file tree Collapse file tree 5 files changed +182
-29
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div id =" app" >
3
- <img alt =" Vue logo" src =" ./assets/logo.png" />
3
+ <img
4
+ alt =" Vue logo"
5
+ src =" ./assets/logo.png"
6
+ />
4
7
<div class =" container " >
5
- <ul class =" nav nav-tabs" role =" tablist" >
8
+ <ul
9
+ class =" nav nav-tabs"
10
+ role =" tablist"
11
+ >
6
12
<li class =" nav-item" >
7
13
<a
8
14
class =" nav-link active"
11
17
role =" tab"
12
18
aria-controls =" profile"
13
19
aria-selected =" true"
14
- >Simple</a
15
- >
20
+ >Simple</a >
16
21
</li >
17
22
18
23
<li class =" nav-item" >
23
28
role =" tab"
24
29
aria-controls =" profile"
25
30
aria-selected =" false"
26
- >Two Lists</a
27
- >
31
+ >Two Lists</a >
28
32
</li >
29
33
30
34
<li class =" nav-item" >
35
39
role =" tab"
36
40
aria-controls =" profile"
37
41
aria-selected =" false"
38
- >Clone</a
39
- >
42
+ >Clone</a >
40
43
</li >
41
44
42
45
<li class =" nav-item" >
43
46
<a
44
47
class =" nav-link"
45
48
data-toggle =" tab"
46
- href =" #footerslot "
49
+ href =" #handler "
47
50
role =" tab"
48
51
aria-controls =" profile"
49
52
aria-selected =" false"
50
- >Footer slot</a
51
- >
53
+ >Handler</a >
52
54
</li >
53
55
54
56
<li class =" nav-item" >
55
57
<a
56
58
class =" nav-link"
57
59
data-toggle =" tab"
58
- href =" #headerlot "
60
+ href =" #transition "
59
61
role =" tab"
60
62
aria-controls =" profile"
61
63
aria-selected =" false"
62
- >Header slot</a
63
- >
64
+ >Transition</a >
64
65
</li >
65
66
66
67
<li class =" nav-item" >
67
68
<a
68
69
class =" nav-link"
69
70
data-toggle =" tab"
70
- href =" #handler "
71
+ href =" #footerslot "
71
72
role =" tab"
72
73
aria-controls =" profile"
73
74
aria-selected =" false"
74
- >Handler</a
75
- >
75
+ >Footer slot</a >
76
76
</li >
77
+
78
+ <li class =" nav-item" >
79
+ <a
80
+ class =" nav-link"
81
+ data-toggle =" tab"
82
+ href =" #headerslot"
83
+ role =" tab"
84
+ aria-controls =" profile"
85
+ aria-selected =" false"
86
+ >Header slot</a >
87
+ </li >
88
+
77
89
</ul >
78
90
79
- <div class =" tab-content" id =" tab-content" >
91
+ <div
92
+ class =" tab-content"
93
+ id =" tab-content"
94
+ >
80
95
<div
81
96
class =" tab-pane show active"
82
97
id =" simple"
115
130
116
131
<div
117
132
class =" tab-pane show"
118
- id =" headerlot "
133
+ id =" headerslot "
119
134
role =" tabpanel"
120
135
aria-labelledby =" profile-tab"
121
136
>
130
145
>
131
146
<handler />
132
147
</div >
148
+
149
+ <div
150
+ class =" tab-pane show"
151
+ id =" transition"
152
+ role =" tabpanel"
153
+ aria-labelledby =" profile-tab"
154
+ >
155
+ <transition-example />
156
+ </div >
133
157
</div >
134
158
</div >
135
159
</div >
@@ -142,6 +166,7 @@ import clone from "./components/clone";
142
166
import footerslot from " ./components/footerslot" ;
143
167
import headerslot from " ./components/headerslot" ;
144
168
import handler from " ./components/handler" ;
169
+ import transitionExample from " ./components/transition-example" ;
145
170
146
171
export default {
147
172
name: " app" ,
@@ -151,7 +176,8 @@ export default {
151
176
clone,
152
177
footerslot,
153
178
headerslot,
154
- handler
179
+ handler,
180
+ transitionExample
155
181
}
156
182
};
157
183
</script >
Original file line number Diff line number Diff line change 7
7
<draggable
8
8
:list =" list"
9
9
class =" list-group"
10
+ :options =" { draggable: '.item' }"
10
11
@start =" dragging = true"
11
12
@end =" dragging = false"
12
13
>
13
14
<div
14
- class =" list-group-item"
15
+ class =" list-group-item item "
15
16
v-for =" element in list"
16
17
:key =" element.name"
17
18
>
Original file line number Diff line number Diff line change 22
22
</draggable >
23
23
</div >
24
24
25
- <rawDisplayer
26
- class =" col-3"
27
- :value =" list"
28
- title =" List"
29
- />
25
+ <rawDisplayer class =" col-3" :value =" list" title =" List" />
30
26
</div >
31
27
</div >
32
28
</template >
33
29
34
30
<script >
35
31
import draggable from " @/vuedraggable" ;
36
32
import rawDisplayer from " ./raw-displayer.vue" ;
37
- let id = 1 ;
38
33
export default {
39
- name: " header " ,
34
+ name: " handler " ,
40
35
components: {
41
36
draggable,
42
37
rawDisplayer
Original file line number Diff line number Diff line change 7
7
<draggable
8
8
:list =" list"
9
9
class =" list-group"
10
+ :options =" { draggable: '.item' }"
10
11
@start =" dragging = true"
11
12
@end =" dragging = false"
12
13
>
13
14
<div
14
- class =" list-group-item"
15
+ class =" list-group-item item "
15
16
v-for =" element in list"
16
17
:key =" element.name"
17
18
>
Original file line number Diff line number Diff line change
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 =" isDragging = true"
20
+ @end =" isDragging = false"
21
+ >
22
+ <transition-group
23
+ type =" transition"
24
+ :name =" 'flip-list'"
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
+ };
82
+ },
83
+ methods: {
84
+ sort (){
85
+ this .list = this .list .sort ((a ,b ) => a .order - b .order );
86
+ }
87
+ },
88
+ computed: {
89
+ dragOptions () {
90
+ return {
91
+ animation: 0 ,
92
+ group: " description" ,
93
+ disabled: false ,
94
+ ghostClass: " ghost"
95
+ };
96
+ }
97
+ }
98
+ };
99
+ </script >
100
+
101
+ <style >
102
+ .button {
103
+ margin-top : 50px ;
104
+ }
105
+
106
+ .flip-list-move {
107
+ transition : transform 0.5s ;
108
+ }
109
+
110
+ .no-move {
111
+ transition : transform 0s ;
112
+ }
113
+
114
+ .ghost {
115
+ opacity : 0.5 ;
116
+ background : #c8ebfb ;
117
+ }
118
+
119
+ .list-group {
120
+ min-height : 20px ;
121
+ }
122
+
123
+ .list-group-item {
124
+ cursor : move ;
125
+ }
126
+
127
+ .list-group-item i {
128
+ cursor : pointer ;
129
+ }
130
+ </style >
You can’t perform that action at this time.
0 commit comments