-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
80 lines (73 loc) · 1.44 KB
/
demo.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>demo</title>
<script src="dist/animation-1.0.0.js"></script>
<style>
body {
font-size: 20px;
font-weight: bold;
}
li {
width: 10px;
margin: 10px 0;
background: #080;
color: #fff;
}
.a1.animation {
transition: 6s;
}
.a2 {
width: 30px;
}
.a3 {
width: 20px;
}
.a3.animation {
transition: 1s;
}
.animation {
transition: 3s;
width: 200px;
}
</style>
</head>
<body>
<h1>Demo</h1>
<ul>
<li class="a1">1</li>
<li class="a2">2</li>
<li class="a3">3</li>
</ul>
<div>
<button id="btn-parallel" type="button">parallel</button>
<button id="btn-series" type="button">series</button>
<button id="btn-race" type="button">race</button>
<button id="btn-reset" type="button" style="color: #f00;">reset</button>
</div>
<script>
function bindClick(selector, handle) {
var el = document.querySelector(selector);
el.addEventListener('click', handle);
}
function done() {
alert('done');
}
bindClick('#btn-parallel', function () {
animation.parallel('li').then(done);
});
bindClick('#btn-series', function () {
animation.series('li').then(done);
});
bindClick('#btn-race', function () {
animation.race('li').then(done);
});
bindClick('#btn-reset', function () {
Array.from(document.querySelectorAll('.animation')).forEach(function (item) {
item.classList.remove('animation');
});
});
</script>
</body>
</html>