-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathindex.html
More file actions
181 lines (157 loc) · 4.25 KB
/
index.html
File metadata and controls
181 lines (157 loc) · 4.25 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html>
<head>
<title>jQuery-Keyframes Example</title>
<script type="text/javascript" src="../node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="../dist/jquery.keyframes.js"></script>
<script type='text/javascript'>
$(document).ready(function() {
// Setup the initial transform style.
$('.ball').css('transform', 'rotate(90deg)');
// Adding a new animation sequences (keyframe)
$.keyframe.define([{
name: 'ball-move',
'0%': {
'margin-left': '0px'
},
'50%': {
'margin-left': '600px'
},
'100%': {
'margin-left': '0px'
}
}, {
name: 'ball-spin',
from: {
'transform': 'rotate(90deg)'
},
to: {
'transform': 'rotate(450deg)'
}
}]);
});
function play(animation) {
$('.ball').resetKeyframe(function() {
switch (animation) {
case 'normal':
// move with easing
$('.ball').playKeyframe({
name: 'ball-move',
duration: "3s",
timingFunction: 'ease',
iterationCount: 'infinite',
direction: 'normal',
fillMode: 'forwards',
complete: increment
});
break;
case 'spin':
// run spin keyframes using the shorthand method.
$('.ball').playKeyframe('ball-spin 500ms linear 0s 3 normal forwards', increment);
break;
case 'linear':
// move with linear timing
$('.ball').playKeyframe({
name: 'ball-move',
duration: "3s",
timingFunction: 'linear',
iterationCount: 'infinite',
complete: increment
});
break;
case 'delay':
// set a 2 second delay before starting
$('.ball').playKeyframe({
name: 'ball-move',
duration: "3s",
timingFunction: 'linear',
delay: "3s",
iterationCount: 'infinite',
complete: increment
});
break;
case 'once':
// only play the animation once
$('.ball').playKeyframe({
name: 'ball-move',
duration: "3s",
timingFunction: 'ease',
complete: increment
});
break;
case 'multi':
// play multiple animations
$('.ball').playKeyframe([
'ball-spin 500ms linear 0s 6',
{
name: 'ball-move',
duration: "3s",
timingFunction: 'ease',
iterationCount: 1
}
],
increment);
break;
default:
$('#cb').html(0);
}
})
}
function pause() {
// freeze keyframe animation and kill callback
$('.ball').pauseKeyframe();
}
function resume() {
// resume keyframe animation
$('.ball').resumeKeyframe();
}
// example callback function
function increment() {
$('#cb').html(parseInt($('#cb').html()) + 1);
}
</script>
<style>
body{
text-align: center;
}
.ball-container {
width:600px;
margin-left:auto;
margin-right:auto;
text-align:center;
margin-top:20px;
}
.ball {
width:100px;
height:90px;
padding-top:10px;
background-color:yellow;
text-align:center;
font-family:tahoma;
font-size:56px;
font-weight:bold;
border-radius: 50px;
box-shadow: 0px 0px 10px 0px #000;
}
</style>
</head>
<body>
<div class="ball-container">
<div class="ball">: )</div>
<br />
<input type="button" onclick="play('normal')" value="Ease Move" />
<input type="button" onclick="play('linear')" value="Linear Move" />
<input type="button" onclick="play('delay')" value="2 Second Delay" />
<input type="button" onclick="play('once')" value="Move Once" />
<input type="button" onclick="play('spin')" value="Spin" />
<input type="button" onclick="play('multi')" value="Multiple Animations" />
<br />
<input type="button" onclick="pause()" value="Pause" />
<input type="button" onclick="resume()" value="Resume" />
<input type="button" onclick="play()" value="Reset" />
<br />
<br />Callback count: <b id="cb">0</b>
<br />
</div>
</body>
</html>