-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
34 lines (31 loc) · 970 Bytes
/
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
document.addEventListener("DOMContentLoaded", function () {
const projects = document.querySelectorAll(".pr");
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("visible");
} else {
entry.target.classList.remove("visible");
}
});
},
{
threshold: 0.1, // Adjust this threshold as needed
}
);
projects.forEach((project) => {
observer.observe(project);
});
window.addEventListener("scroll", function () {
projects.forEach((project) => {
const img = project.querySelector(".pr-img");
const curve = project.querySelector(".curve-line");
if (img && curve) {
const imgRect = img.getBoundingClientRect();
curve.style.top = `${imgRect.top + window.scrollY}px`;
curve.style.left = `${imgRect.left + window.scrollX}px`;
}
});
});
});