-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
81 lines (70 loc) · 2.41 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
<!DOCTYPE html>
<html>
<head>
<title>My Lottie File</title>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<linkhref="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet" />
<link href="styles.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.7.7/lottie.min.js" type="text/javascript"></script>
<script>
window.onload = (event) => {
const brain = lottie.loadAnimation({
container: document.getElementById("myLottie"),
renderer: "svg",
loop: true,
autoplay: false,
path: "https://assets9.lottiefiles.com/packages/lf20_2fWXlk.json",
});
brain.addEventListener("DOMLoaded", function () {
brain.playSegments([0, 60], true);
});
const btnWakeUp = document.getElementById("btnWakeUp");
btnWakeUp.addEventListener("click", () => {
brain.playSegments(
[
[60, 90],
[90, 190],
],
true
);
});
const btnSleep = document.getElementById("btnSleep");
btnSleep.addEventListener("click", () => {
brain.setDirection(1);
brain.playSegments([90, 0], true);
brain.playSegments([0, 60], false);
});
const btnBigSmile = document.getElementById("btnBigSmile");
btnBigSmile.addEventListener("click", () => {
brain.playSegments(
[
[190, 210],
[210, 290],
],
true
);
});
const btnSwing = document.getElementById("btnSwing");
btnSwing.addEventListener("click", () => {
brain.playSegments([290, 340], true);
});
const btnJump = document.getElementById("btnJump");
btnJump.addEventListener("click", () => {
brain.playSegments([340, 374], true);
});
};
</script>
</head>
<body>
<div class="container">
<div id="myLottie"></div>
<div id="control-bar">
<button class="button" id="btnWakeUp">Wake Up</button>
<button class="button" id="btnBigSmile">Be Happy</button>
<button class="button" id="btnSwing">Swing</button>
<button class="button" id="btnJump">Jump</button>
<button class="button" id="btnSleep">Sleep</button>
</div>
</div>
</body>
</html>