forked from ics-creative/220617_gsap_example
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathonUpdate.html
54 lines (52 loc) · 1.15 KB
/
onUpdate.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/gsap.min.js"></script>
<script>
window.addEventListener("DOMContentLoaded", () => {
const params = { radian: 0 };
gsap.to(params, {
radian: Math.PI * 2,
duration: 2,
ease: "power4.inOut",
onUpdate: () => {
const { radian } = params;
const x = Math.cos(radian) * 100;
const y = Math.sin(radian) * 100;
gsap.set(".circle", { x, y });
},
repeat: -1,
});
});
</script>
<style>
html {
height: 100%;
}
body {
margin: 0;
padding: 0;
background: #000;
height: 100%;
display: grid;
place-items: center;
}
.container {
}
.circle {
width: 10vw;
height: 10vw;
border-radius: 50%;
display: block;
background: white;
position: relative;
}
</style>
</head>
<body>
<div class="container">
<div class="circle"></div>
</div>
</body>
</html>