-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
65 lines (54 loc) · 2.2 KB
/
script.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
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
const container = document.querySelector(".container");
document.addEventListener("DOMContentLoaded", () => {
container.addEventListener("scroll", (event) => {
const introSection = document.getElementById("intro");
const arrow = document.getElementById("scroll-arrow");
const link = document.getElementById("scroll-link");
let rect = introSection.getBoundingClientRect();
if (rect.top == -4072) {
arrow.style.display = "none";
} else if (rect.top <= -3054) {
link.setAttribute("href", "#contact");
arrow.style.display = "inline-block";
} else if (rect.top <= -2036) {
link.setAttribute("href", "#about");
arrow.style.display = "inline-block";
} else if (rect.top <= -1018) {
link.setAttribute("href", "#old-projects");
arrow.style.display = "inline-block";
} else if (rect.top <= 0) {
link.setAttribute("href", "#new-projects");
arrow.style.display = "inline-block";
}
});
document.querySelector(".new-cards").addEventListener("mousemove", (e) => {
document.querySelectorAll(".card").forEach((card) => {
const rect = card.getBoundingClientRect(),
x = e.clientX - rect.left,
y = e.clientY - rect.top;
card.style.setProperty("---mouse-x", `${x}px`);
card.style.setProperty("--mouse-y", `${y}px`);
});
});
document.querySelector(".old-cards").addEventListener("mousemove", (e) => {
document.querySelectorAll(".card").forEach((card) => {
const rect = card.getBoundingClientRect(),
x = e.clientX - rect.left,
y = e.clientY - rect.top;
card.style.setProperty("---mouse-x", `${x}px`);
card.style.setProperty("--mouse-y", `${y}px`);
});
});
document
.querySelector(".contact-cards")
.addEventListener("mousemove", (e) => {
document.querySelectorAll(".contact-icon").forEach((card) => {
const rect = card.getBoundingClientRect(),
x = e.clientX - rect.left,
y = e.clientY - rect.top;
card.style.setProperty("---mouse-x", `${x}px`);
card.style.setProperty("--mouse-y", `${y}px`);
});
});
// Add a event listener to detect when the user isn't on the intro section and hide the arrow image
});