-
Notifications
You must be signed in to change notification settings - Fork 0
/
animate_exercise.html
105 lines (87 loc) · 2.56 KB
/
animate_exercise.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html>
<head>
<title>Animate</title>
<style>
html, body {
margin: 0px;
padding: 0;
}
#btn-animate {
margin: 15px;
}
#animate-box {
background-color: #000033;
height: 250px;
margin: 15px;
position: relative;
width: 250px;
}
</style>
</head>
<body>
<p>
<button id="btn-move">Move It</button>
<button id="btn-scale">Scale It</button>
<button id="btn-hide">Hide It</button>
<button id="btn-show">Show It</button>
<button id="btn-all">Animate All</button>
</p>
<div id="animate-box"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
$(document).ready(function() {
"use strict";
var $box = $('#animate-box');
// TODO: "Move It" should move the box 100 pixels to the left
$('#btn-move').click(function(){boxmove()});
function boxmove(){
$box.animate({
left: '+=50px'
}, 1000);
}
// TODO: "Scale It" should expand the box width by 50%
$('#btn-scale').click(function(){boxscale()});
function boxscale(){
$box.animate({
width: '+=125px'
}, 1000);
}
// TODO: "Hide It" should use opacity to make the box invisible
$('#btn-hide').click(function(){boxhide()});
function boxhide(){
$box.animate({
opacity: '0'
}, 1000)
}
// TODO: "Show It" should make the box appear
$('#btn-show').click(function(){boxshow()});
function boxshow(){
$box.animate({
opacity: '100'
}, 1000)
}
// TODO: "Animate All" should use an animation stack to:
// 1) Move and scale the box simultaneously
// 2) Hide the box
// 3) Reset the box back to its original position and opacity
$('#btn-all').click(function(){
$box.animate({
left: '+=50px',
width: '+=125px'
}, 2000, function(){
$box.animate({
opacity: '0'
}, 2000, function(){
$box.animate({
opacity: '100',
width: '250px',
left: '0'
}, 3000);
});
});
});
});
</script>
</body>
</html>