-
Notifications
You must be signed in to change notification settings - Fork 37
/
bounce.html
86 lines (84 loc) · 3.61 KB
/
bounce.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Raphaël · Bouncer</title>
<link rel="stylesheet" href="demo.css" media="screen">
<link rel="stylesheet" href="demo-print.css" media="print">
<style media="screen">
#holder {
height: 400px;
margin: -200px 0 0 -200px;
width: 400px;
}
#form {
position: absolute;
top: 50%;
left: 50%;
width: 400px;
height: 100px;
margin: -200px 0 0 -200px;
}
</style>
<script src="raphael.js"></script>
<script>
Raphael(function () {
var r = Raphael("holder"),
easingx = document.getElementById("easingx"),
easingy = document.getElementById("easingy"),
run = document.getElementById("run"),
set = r.set(r.circle(300, 200, 8),r.circle(200, 100, 8),r.circle(100, 200, 8),r.circle(200, 300, 8),r.circle(200, 200, 8)).attr({stroke: "none", fill: "#666"}),
c = r.circle(200, 200, 10).attr({stroke: "#fff", "stroke-width": 4}),
fade = function (id) {
return function () {
set[id].attr({fill: "#fff", r: 12}).animate({fill: "#666", r: 8}, 500);
};
};
run.onclick = function () {
var ex = easingx.value,
ey = easingy.value;
c.stop().animate({
"20%": {cy: 200, easing: ey, callback: fade(0)},
"40%": {cy: 100, easing: ey, callback: fade(1)},
"60%": {cy: 200, easing: ey, callback: fade(2)},
"80%": {cy: 300, easing: ey, callback: fade(3)},
"100%": {cy: 200, easing: ey, callback: fade(4)}
}, 5000).animate({
"20%": {cx: 300, easing: ex},
"40%": {cx: 200, easing: ex},
"60%": {cx: 100, easing: ex},
"80%": {cx: 200, easing: ex},
"100%": {cx: 200, easing: ex}
}, 5000);
};
});
</script>
</head>
<body>
<div id="holder"></div>
<div id="form">
<select id="easingx">
<option value="">Linear</option>
<option value=">">Ease In</option>
<option value="<">Ease Out</option>
<option value="<>">Ease In and Out</option>
<option value="bounce">Bounce</option>
<option value="elastic">Elastic</option>
<option value="backIn">Back In</option>
<option value="backOut">Back Out</option>
</select>
<select id="easingy">
<option value="">Linear</option>
<option value=">">Ease In</option>
<option value="<">Ease Out</option>
<option value="<>">Ease In and Out</option>
<option value="bounce">Bounce</option>
<option value="elastic">Elastic</option>
<option value="backIn">Back In</option>
<option value="backOut">Back Out</option>
</select>
<button id="run">Run</button>
</div>
<p id="copy">Demo of <a href="http://raphaeljs.com/">Raphaël</a>—JavaScript Vector Library</p>
</body>
</html>