-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
147 lines (124 loc) · 4.2 KB
/
Copy pathscript.js
File metadata and controls
147 lines (124 loc) · 4.2 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
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
document.addEventListener("DOMContentLoaded", () => {
const minLoadTime = 3000;
const maxLoadTime = 8000;
const startTime = Date.now();
const loader = document.getElementById("msepm-loader");
const content = document.getElementById("msepm-main-content");
let loaderRemoved = false;
function removeLoader() {
if (loaderRemoved) return;
const elapsed = Date.now() - startTime;
const remaining = Math.max(0, minLoadTime - elapsed);
setTimeout(() => {
loaderRemoved = true;
if (loader) {
loader.classList.add("finished");
}
if (content) {
content.classList.add("visible");
}
setTimeout(() => {
if (typeof highlightCenterSlide === "function") {
highlightCenterSlide();
}
}, 300);
}, remaining);
}
if (document.readyState === "complete") {
removeLoader();
} else {
window.addEventListener("load", removeLoader);
}
setTimeout(() => {
if (!loaderRemoved) {
removeLoader();
}
}, maxLoadTime);
});
const menuBtn = document.getElementById("menuBtn");
const nav = document.getElementById("nav");
const navLinks = document.querySelectorAll(".navList");
const menuIcon = menuBtn ? menuBtn.querySelector(".menu-icon") : null;
if (menuBtn && nav && menuIcon) {
menuBtn.addEventListener("click", () => {
const isOpen = nav.classList.toggle("active");
menuIcon.innerHTML = isOpen ? "✕" : "☰";
menuBtn.setAttribute("aria-expanded", isOpen);
});
navLinks.forEach((link) => {
link.addEventListener("click", () => {
nav.classList.remove("active");
menuIcon.innerHTML = "☰";
menuBtn.setAttribute("aria-expanded", "false");
});
});
}
const trackedSections = Array.from(navLinks).map((link) =>
document.querySelector(link.getAttribute("href"))
).filter(Boolean);
function setActiveLink(id) {
navLinks.forEach((link) => {
link.classList.toggle("active", link.getAttribute("href") === "#" + id);
});
}
const sectionObserver = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) setActiveLink(entry.target.id);
});
},
{ rootMargin: "-80px 0px -60% 0px" }
);
trackedSections.forEach((section) => sectionObserver.observe(section));
window.addEventListener("scroll", () => {
const reachedBottom = window.innerHeight + window.scrollY >= document.body.offsetHeight - 2;
if (reachedBottom) setActiveLink("contact");
});
const galleryTrack = document.getElementById("galleryTrack");
const galleryItems = document.querySelectorAll(".gallery-item");
const galleryPrev = document.getElementById("galleryPrev");
const galleryNext = document.getElementById("galleryNext");
if (galleryPrev && galleryTrack) {
galleryPrev.addEventListener("click", () => {
galleryTrack.scrollBy({ left: -260, behavior: "smooth" });
});
}
if (galleryNext && galleryTrack) {
galleryNext.addEventListener("click", () => {
galleryTrack.scrollBy({ left: 260, behavior: "smooth" });
});
}
function highlightCenterSlide() {
if (!galleryTrack || galleryItems.length === 0) return;
const trackCenter = galleryTrack.getBoundingClientRect().left + galleryTrack.offsetWidth / 2;
let closestItem = galleryItems[0];
let closestDistance = Infinity;
galleryItems.forEach((item) => {
const itemCenter = item.getBoundingClientRect().left + item.offsetWidth / 2;
const distance = Math.abs(itemCenter - trackCenter);
if (distance < closestDistance) {
closestDistance = distance;
closestItem = item;
}
});
galleryItems.forEach((item) => item.classList.remove("is-center"));
closestItem.classList.add("is-center");
}
if (galleryTrack) {
galleryTrack.addEventListener("scroll", () => requestAnimationFrame(highlightCenterSlide));
}
window.addEventListener("load", highlightCenterSlide);
fetch("https://hook.us2.make.com/m981aperxnqb2bmv4ki3evkttrj7e8ve", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
date: new Date().toLocaleDateString(),
time: new Date().toLocaleTimeString(),
browser: navigator.userAgent,
screen: `${screen.width}x${screen.height}`,
language: navigator.language,
page: window.location.href
})
}).catch(() => {});