-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (32 loc) · 1.06 KB
/
script.js
File metadata and controls
40 lines (32 loc) · 1.06 KB
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
const revealItems = document.querySelectorAll(".reveal");
const revealObserver = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("show");
revealObserver.unobserve(entry.target);
}
});
},
{
threshold: 0.12,
rootMargin: "0px 0px -40px 0px"
}
);
revealItems.forEach((item) => revealObserver.observe(item));
const heroPanel = document.querySelector(".hero-main");
if (heroPanel) {
heroPanel.addEventListener("mousemove", (e) => {
if (window.innerWidth < 900) return;
const rect = heroPanel.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const rotateY = ((x / rect.width) - 0.5) * 3;
const rotateX = ((y / rect.height) - 0.5) * -3;
heroPanel.style.transform =
`perspective(900px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
});
heroPanel.addEventListener("mouseleave", () => {
heroPanel.style.transform = "perspective(900px) rotateX(0deg) rotateY(0deg)";
});
}