This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathexample.html
80 lines (77 loc) · 2.09 KB
/
example.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue animated list example</title>
<script src="https://cdn.jsdelivr.net/lodash/4.3.0/lodash.min.js"></script>
<script src="https://cdn.jsdelivr.net/vue/1.0.16/vue.min.js"></script>
<script src="./vue-animated-list.js"></script>
<style>
.container {
width: 300px;
}
.item {
box-sizing: border-box;
background-color: #eee;
border: 1px solid black;
display: inline-block;
width: 100px;
height: 100px;
}
.item-transition {
transition: opacity .5s ease;
}
.item-enter {
opacity: 0;
}
.item-leave {
opacity: 0;
position: absolute; /* important for removal move to work */
}
.item-move {
color: red;
transition: transform .5s cubic-bezier(.55,0,.1,1); /* applied when moving */
}
</style>
</head>
<body>
<p style="max-width: 500px">
This is a demo of the <a href="https://github.com/vuejs/vue-animated-list">vue-animated-list</a> plugin. It doesn't require any changes to how data is manipulated in JavaScript - just add a CSS class and you get smooth 60fps animations. <a href="https://github.com/vuejs/vue-animated-list/blob/master/example.html">Source</a>
</p>
<div id="el">
<button @click="shuffle">shuffle</button>
<button @click="add">add</button>
<button @click="remove">remove</button>
<div class="container">
<div class="item"
v-for="item in items"
transition="item">
{{item.text}}
</div>
</div>
</div>
<script>
var items = []
for (var i = 0; i < 9; i++) {
items.push({ text: i })
}
var vm = new Vue({
el: '#el',
data: {
items: items
},
methods: {
shuffle: function () {
this.items = _.shuffle(this.items)
},
add: function () {
this.items.unshift({ text: this.items.length })
},
remove: function () {
this.items.shift()
}
}
})
</script>
</body>
</html>