-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
62 lines (54 loc) · 2.04 KB
/
Copy pathscript.js
File metadata and controls
62 lines (54 loc) · 2.04 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
/* ═══════════════════════════════════════════
SCRIPT.JS — Header, Mobil Menü, Animasyonlar
═══════════════════════════════════════════ */
const header = document.querySelector("[data-header]");
const menuButton = document.querySelector("[data-menu-button]");
const mobilePanel = document.querySelector("[data-mobile-panel]");
/* ─── Header scroll durumu ─── */
const setHeaderState = () => {
if (header) {
header.classList.toggle("is-scrolled", window.scrollY > 20);
}
};
setHeaderState();
window.addEventListener("scroll", setHeaderState, { passive: true });
/* ─── Mobil menü aç/kapat ─── */
const closeMenu = () => {
document.body.classList.remove("menu-open");
if (mobilePanel) mobilePanel.classList.remove("is-open");
if (menuButton) menuButton.setAttribute("aria-label", "Menüyü aç");
};
if (menuButton) {
menuButton.addEventListener("click", () => {
const isOpen = mobilePanel.classList.toggle("is-open");
document.body.classList.toggle("menu-open", isOpen);
menuButton.setAttribute("aria-label", isOpen ? "Menüyü kapat" : "Menüyü aç");
});
}
if (mobilePanel) {
mobilePanel.querySelectorAll("a").forEach((link) => {
link.addEventListener("click", closeMenu);
});
}
/* ─── Reveal animasyonları (Intersection Observer) ─── */
const revealItems = document.querySelectorAll(".reveal");
if (revealItems.length) {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("is-visible");
observer.unobserve(entry.target);
}
});
},
{ threshold: 0.15 }
);
revealItems.forEach((item) => observer.observe(item));
}
/* ─── Lucide ikonları yükle ─── */
window.addEventListener("load", () => {
if (window.lucide) {
window.lucide.createIcons();
}
});