-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimation.html
79 lines (68 loc) · 2.08 KB
/
animation.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Zelda man moving around</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="animation.css">
</head>
<body>
<input type="button" onclick="right()" value="right">
<input type="button" onclick="left()" value="left">
<input type="button" onclick="up()" value="up">
<input type="button" onclick="down();" value="down">
<input type="button" onclick="stop();" value="stop">
<input type="button" onclick="reset();" value="reset">
<div id="container" >
<div id="rightLeft">
<div id="old-man" class="zelda-old-man"></div>
</div>
</div>
</body>
<script>
let oldMan = document.getElementById("old-man")
let rightLeft = document.getElementById("rightLeft")
let moveRight = { transform: ["translateX(0)", "translateX(100vw)"] }
let moveDown = { transform: ["translateY(0)", "translateY(100vw)"] }
let h = rightLeft.animate(
moveRight
, 8000);
h.pause()
let a = oldMan.animate(
moveDown
, 8000);
a.pause()
// a.pause()
function right() {
h.playbackRate = 1;
h.play()
// { transform: ["translateX(0)", "translateX(300px)", "translateX(0)"], transform: ["translateY(0)", "translateY(300px)", "translateY(0)"] }, 5000);
console.log(oldMan.getAnimations)
}
function stop() {
a.pause()
h.pause()
}
function up() {
a.play();
a.playbackRate = -1;
}
function left() {
h.playbackRate = -1;
h.play()
}
function down() {
a.playbackRate = 1;
a.play();
}
function reset() {
a.finish()
h.finish()
}
// function save() {
// oldManStyle.backgroundPositionX = oldMan.getBoundingClientRect().x;
// oldManStyle.y = oldMan.getBoundingClientRect().y;
// }
</script>
</html>