-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
91 lines (81 loc) · 3.33 KB
/
script.js
File metadata and controls
91 lines (81 loc) · 3.33 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
document.addEventListener("DOMContentLoaded", function () {
// Mobile Nav Toggle
const navToggle = document.querySelector(".nav-toggle");
const sideNav = document.querySelector(".sidebar-nav");
const mobileHeader = document.querySelector(".mobile-header");
if (navToggle) {
navToggle.addEventListener("click", function () {
// In mobile view, we might want to show the sidebar as an overlay
if (window.innerWidth <= 900) {
const isVisible = getComputedStyle(sideNav).display !== 'none';
if (isVisible) {
sideNav.style.display = 'none';
} else {
sideNav.style.display = 'block';
sideNav.style.position = 'fixed';
sideNav.style.top = mobileHeader.offsetHeight + 'px';
sideNav.style.width = '100%';
sideNav.style.height = `calc(100vh - ${mobileHeader.offsetHeight}px)`;
}
}
});
}
// Active Link Highlighting
const currentPath = window.location.pathname.split("/").pop() || "index.html";
document.querySelectorAll(".side-nav .nav-link").forEach(link => {
const href = link.getAttribute("href");
if (href === currentPath) {
link.classList.add("is-active");
} else {
link.classList.remove("is-active");
}
});
// Reveal animations on scroll
const reveals = document.querySelectorAll(".reveal");
const observerOptions = {
threshold: 0.1,
rootMargin: "0px 0px -50px 0px"
};
const revealObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add("is-visible");
observer.unobserve(entry.target);
}
});
}, observerOptions);
reveals.forEach(el => revealObserver.observe(el));
// Smooth scroll for internal links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const targetElement = document.querySelector(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
// Close mobile menu if open
if (window.innerWidth <= 900) {
sideNav.style.display = 'none';
}
}
});
});
const motionFrame = document.getElementById("motion-iframe");
if (motionFrame) {
const updateMotionHeight = (height) => {
const nextHeight = Number(height);
if (!Number.isFinite(nextHeight) || nextHeight <= 0) return;
motionFrame.style.height = `${Math.max(320, Math.round(nextHeight))}px`;
};
window.addEventListener("message", (event) => {
if (event.source !== motionFrame.contentWindow) return;
const data = event.data;
if (!data || data.type !== "tg-iframe-height") return;
updateMotionHeight(data.height);
});
}
});