-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
41 lines (34 loc) · 887 Bytes
/
main.ts
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
import gsap from "gsap";
document.addEventListener("DOMContentLoaded", function (event) {
const container = document.getElementById("container");
const rows = 6;
const cols = 6;
let html = "";
for (let i = 0; i < rows * cols; i++) {
html += '<div class="bg-black box h-[50px] w-[50px]"></div>';
}
let html2 = "";
for (let i = 0; i < rows * cols; i++) {
html2 += `<div class="">${html}</div>`;
}
if (container) {
container.innerHTML = html2;
}
const boxes = document.querySelectorAll(".box");
boxes.forEach((box, index) => {
box.addEventListener("mouseenter", () => {
gsap.to(box, {
duration: 0.5,
opacity: 0,
ease: "elastic",
});
});
box.addEventListener("mouseleave", () => {
gsap.to(box, {
duration: 0.5,
opacity: 1,
ease: "elastic",
});
});
});
});