-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
32 lines (25 loc) · 810 Bytes
/
main.js
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
document.addEventListener('DOMContentLoaded', () => {
const interBubble = document.querySelector('.interactive');
if (!interBubble) return; // Prevent errors if element doesn't exist
let curX = 0;
let curY = 0;
let tgX = 0;
let tgY = 0;
function move() {
curX += (tgX - curX) / 20;
curY += (tgY - curY) / 20;
interBubble.style.transform = `translate(${Math.round(curX)}px, ${Math.round(curY)}px)`;
requestAnimationFrame(() => {
move();
});
}
window.addEventListener('mousemove', (event) => {
tgX = event.clientX;
tgY = event.clientY;
});
move();
});
onload = () =>{
document.body.classList.remove("container");
document.body.style.overflow = 'hidden';
};