-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
99 lines (84 loc) · 2.71 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
body {
background-color: rgb(133 208 187);
}
.backgroud {
background-image: url("background.jpg");
background-position: center;
background-repeat: no-repeat;
height: 400px;
background-size: cover;
margin: auto;
}
.backgroud img {
position: relative;
top: 200px;
}
.shape {
width: 250px;
height: 150px;
}
.Buttons {
width: 40%;
margin: auto;
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 40px;
}
.Buttons button {
padding: 10px;
border-radius: 5px;
background-color: #121113;
color: white;
}
</style>
<script>
window.addEventListener("load", function() {
var shapeElement = document.querySelector(".shape");
var frames = [{
transform: "translateX(0px)"
}, {
transform: "translateX(1400px)"
}, ];
var timing = {
duration: 5000,
iterations: Infinity,
//direction: "alternate"
}
var shapeAnimate = shapeElement.animate(frames, timing);
document.querySelector(".play").addEventListener("click", function() {
shapeAnimate.play();
});
document.querySelector(".pause").addEventListener("click", function() {
shapeAnimate.pause();
});
document.querySelector(".reverse").addEventListener("click", function() {
shapeAnimate.reverse();
});
document.querySelector(".updatePlaybackRate").addEventListener("click", function() {
shapeAnimate.updatePlaybackRate(shapeAnimate.playbackRate * 1.2);
});
document.querySelector(".slowPlaybackRate").addEventListener("click", function() {
shapeAnimate.updatePlaybackRate(shapeAnimate.playbackRate / 1.2);
});
})
</script>
</head>
<body>
<div class="backgroud">
<img class="shape" src="redCar.png">
</div>
<div class="Buttons">
<button class="play">Play</button>
<button class="pause">Pause</button>
<button class="reverse">Reverse</button>
<button class="updatePlaybackRate">Fast Speed</button>
<button class="slowPlaybackRate">Slow Speed</button>
</div>
</body>
</html>