-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
201 lines (182 loc) · 8.16 KB
/
script.js
File metadata and controls
201 lines (182 loc) · 8.16 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// ── Init Lucide icons ──────────────────────────────────────
lucide.createIcons();
// ── THEME TOGGLE ───────────────────────────────────────────
const html = document.documentElement;
const toggleBtn = document.getElementById("theme-toggle");
const iconSun = document.getElementById("theme-icon-sun");
const iconMoon = document.getElementById("theme-icon-moon");
function applyTheme(t) {
html.setAttribute("data-theme", t);
localStorage.setItem("vs-theme", t);
if (t === "light") {
iconSun.classList.add("hidden");
iconMoon.classList.remove("hidden");
} else {
iconMoon.classList.add("hidden");
iconSun.classList.remove("hidden");
}
}
toggleBtn.addEventListener("click", () =>
applyTheme(html.getAttribute("data-theme") === "dark" ? "light" : "dark")
);
applyTheme(localStorage.getItem("vs-theme") || "dark");
// ── MOBILE MENU ────────────────────────────────────────────
const hamburger = document.getElementById("hamburger");
const mobileMenu = document.getElementById("mobile-menu");
hamburger.addEventListener("click", () => mobileMenu.classList.toggle("hidden"));
document.querySelectorAll("#mobile-menu a").forEach(a =>
a.addEventListener("click", () => mobileMenu.classList.add("hidden"))
);
// ── ACTIVE NAV ON SCROLL ───────────────────────────────────
const navLinks = document.querySelectorAll(".nav-link");
new IntersectionObserver(entries => {
entries.forEach(e => {
if (e.isIntersecting) {
navLinks.forEach(l => l.classList.remove("active"));
document.querySelectorAll(`.nav-link[href="#${e.target.id}"]`)
.forEach(l => l.classList.add("active"));
}
});
}, { rootMargin: "-38% 0px -55% 0px" })
.observe && document.querySelectorAll("section[id]")
.forEach(s => new IntersectionObserver(entries => {
if (entries[0].isIntersecting) {
navLinks.forEach(l => l.classList.remove("active"));
document.querySelectorAll(`.nav-link[href="#${s.id}"]`)
.forEach(l => l.classList.add("active"));
}
}, { rootMargin:"-38% 0px -55% 0px" }).observe(s));
// ── SCROLL-REVEAL ──────────────────────────────────────────
const ro = new IntersectionObserver(entries => {
entries.forEach(e => {
if (e.isIntersecting) {
e.target.classList.add("visible");
ro.unobserve(e.target);
}
});
}, { threshold: 0.07 });
document.querySelectorAll(".reveal").forEach((el, i) => {
el.style.transitionDelay = `${i * 0.04}s`;
ro.observe(el);
});
// stagger groups
document.querySelectorAll(".stagger").forEach(g => ro.observe(g));
// ── TYPING ANIMATION ──────────────────────────────────────
const typedEl = document.getElementById("typed-name");
const titleEl = document.getElementById("hero-title");
// Roles to type out
const typedRoles = [
"Python Developer",
"Web Developer",
"Data Analyst",
];
let roleIdx = 0, cIdx = 0, del = false;
function typeLoop() {
const text = typedRoles[roleIdx];
if (del) {
cIdx--;
typedEl.textContent = text.slice(0, cIdx);
if (cIdx === 0) {
del = false;
roleIdx = (roleIdx + 1) % typedRoles.length;
setTimeout(typeLoop, 380);
return;
}
setTimeout(typeLoop, 48);
} else {
cIdx++;
typedEl.textContent = text.slice(0, cIdx);
if (cIdx === text.length) {
setTimeout(() => { del = true; typeLoop(); }, 2200);
return;
}
setTimeout(typeLoop, 85);
}
}
setTimeout(typeLoop, 800);
// ── ROLE ROTATOR ───────────────────────────────────────────
const roles = ["CSE-AIML Student", "Passout year 2026"];
let rIdx = 0;
const roleEl = document.getElementById("role-text");
setInterval(() => {
roleEl.style.opacity = "0";
roleEl.style.transform = "translateY(-5px)";
setTimeout(() => {
rIdx = (rIdx + 1) % roles.length;
roleEl.textContent = roles[rIdx];
roleEl.style.transition = "all 0.38s ease";
roleEl.style.opacity = "1";
roleEl.style.transform = "translateY(0)";
}, 280);
roleEl.style.transition = "all 0.25s ease";
}, 2600);
// ── CERT MODAL ─────────────────────────────────────────────
const certOverlay = document.getElementById("portfolio-modal");
const mImg = document.getElementById("modal-img");
const mTitle= document.getElementById("modal-title");
const mIss = document.getElementById("modal-issuer");
const mDesc = document.getElementById("modal-description");
const mDate = document.getElementById("modal-date");
function openModal(title, issuer, desc, date, src) {
mTitle.textContent = title; mIss.textContent = issuer;
mDesc.textContent = desc; mDate.textContent = date;
mImg.src = src;
certOverlay.classList.remove("hidden");
requestAnimationFrame(() => certOverlay.classList.add("open"));
document.body.style.overflow = "hidden";
}
function closeModal() {
certOverlay.classList.remove("open");
setTimeout(() => { certOverlay.classList.add("hidden"); document.body.style.overflow = ""; }, 320);
}
// ── PROJECT MODAL ──────────────────────────────────────────
const projOverlay = document.getElementById("project-modal");
const projTitle = document.getElementById("project-modal-title");
const projVideoCont = document.getElementById("project-modal-video-container");
const projVideo = document.getElementById("project-modal-video");
const projShots = document.getElementById("project-modal-screenshots");
function openProjectModal(title, shots, videoSrc) {
projTitle.textContent = title;
videoSrc ? (projVideo.src = videoSrc, projVideoCont.classList.remove("hidden"))
: projVideoCont.classList.add("hidden");
projShots.innerHTML = "";
const pc = shots.filter(s => s.includes("PC-Dashboard"));
const mob = shots.filter(s => s.includes("Mobile-Dashboard"));
const oth = shots.filter(s => !s.includes("PC-Dashboard") && !s.includes("Mobile-Dashboard"));
function addImgs(list) {
list.forEach(src => {
const img = document.createElement("img");
img.src = src; img.alt = title;
img.className = "w-full h-auto rounded-xl border border-white/10 cursor-pointer hover:border-indigo-500 transition";
img.onclick = () => window.open(src, "_blank");
projShots.appendChild(img);
});
}
if (pc.length || mob.length) {
if (pc.length) { addLabel("🖥️ PC Dashboard"); addImgs(pc); }
if (mob.length) { addLabel("📱 Mobile Dashboard"); addImgs(mob); }
} else { addImgs(oth); }
projOverlay.classList.remove("hidden");
requestAnimationFrame(() => projOverlay.classList.add("open"));
document.body.style.overflow = "hidden";
}
function addLabel(txt) {
const p = document.createElement("p");
p.className = "col-span-full text-xs font-bold uppercase tracking-widest text-indigo-400 mt-2 mb-2";
p.textContent = txt; projShots.appendChild(p);
}
function closeProjectModal() {
projOverlay.classList.remove("open");
projVideo.pause(); projVideo.currentTime = 0;
setTimeout(() => { projOverlay.classList.add("hidden"); document.body.style.overflow = ""; }, 320);
}
// ── ESC TO CLOSE ───────────────────────────────────────────
document.addEventListener("keydown", e => {
if (e.key === "Escape") {
if (!certOverlay.classList.contains("hidden")) closeModal();
if (!projOverlay.classList.contains("hidden")) closeProjectModal();
}
});
// ── RE-INIT ICONS AFTER THEME CHANGE ──────────────────────
new MutationObserver(() => lucide.createIcons())
.observe(html, { attributes: true, attributeFilter: ["data-theme"] });