-
Notifications
You must be signed in to change notification settings - Fork 476
/
Copy path06 2animation.html
88 lines (83 loc) · 2.47 KB
/
06 2animation.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
81
82
83
84
85
86
87
88
Ó<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>06</title>
<script src="vue.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<!--使用 animate.css -->
<link rel="stylesheet" href="animate.css">
<style>
#example {
width: 500px;
height: 300px;
background-color: yellow;
}
</style>
</head>
<body>
<h3>animation 高级活用,hover,click 绑定,与 vue transition
</h3>
<div id="example">
<div v-show="ok" class="animated" transition="bounce">
<div id="jsanimation1">
此元素 hover 事件
<a href='https://daneden.github.io/animate.css/' target='_new'>
animate.css
</a>
</div>
<div id="jsanimation2">
此元素 click
</div>
</div>
<button @click="ok=!ok">ok:{{ok}}</button>
</div>
<script>
Vue.transition('bounce', {
type: 'animation',
enterClass: 'bounceInLeft',
leaveClass: 'bounceOutRight'
})
var vm = new Vue({
el: '#example',
data: {
ok: true
},
})
// ***************************************
// * 将 animation.css , 绑定在 元素的 Hover
// *
function animationHover(element, animation) {
element = $(element);
element.hover(
function() {
element.addClass('animated ' + animation);
},
function() {
//wait for animation to finish before removing classes
window.setTimeout(function() {
element.removeClass('animated ' + animation);
}, 2000);
}
);
};
animationHover('#jsanimation1', 'hinge');
// ***************************************
// * 将 animation.css , 绑定在 元素的 click
// *
function animationClick(element, animation) {
element = $(element);
element.click(
function() {
element.addClass('animated ' + animation);
//wait for animation to finish before removing classes
window.setTimeout(function() {
element.removeClass('animated ' + animation);
}, 2000);
}
);
};
animationClick('#jsanimation2', 'zoomOutDown');
</script>
</body>
</html>