-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
88 lines (73 loc) · 2.69 KB
/
script.js
File metadata and controls
88 lines (73 loc) · 2.69 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
// ============================================
// NAMISH PARASHER — PORTFOLIO SCRIPT
// ============================================
document.addEventListener('DOMContentLoaded', () => {
// ── Navbar scroll shrink ──────────────────
const navbar = document.getElementById('navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 60) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// ── Mobile nav toggle ─────────────────────
const toggle = document.getElementById('navToggle');
const navLinks = document.querySelector('.nav-links');
toggle.addEventListener('click', () => {
navLinks.classList.toggle('open');
});
// Close mobile nav on link click
navLinks.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
navLinks.classList.remove('open');
});
});
// ── Scroll reveal ─────────────────────────
const revealEls = document.querySelectorAll(
'.exp-item, .skill-card, .edu-item, .about-grid, .contact-links, .section-title, .section-label'
);
revealEls.forEach(el => el.classList.add('reveal'));
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry, i) => {
if (entry.isIntersecting) {
// Stagger children in lists
const delay = entry.target.dataset.delay || 0;
setTimeout(() => {
entry.target.classList.add('visible');
}, delay);
observer.unobserve(entry.target);
}
});
},
{ threshold: 0.1, rootMargin: '0px 0px -40px 0px' }
);
// Add stagger delays to grid/list children
document.querySelectorAll('.exp-item').forEach((el, i) => {
el.dataset.delay = i * 80;
});
document.querySelectorAll('.skill-card').forEach((el, i) => {
el.dataset.delay = i * 60;
});
revealEls.forEach(el => observer.observe(el));
// ── Active nav link on scroll ─────────────
const sections = document.querySelectorAll('section[id]');
const links = document.querySelectorAll('.nav-links a');
const sectionObserver = new IntersectionObserver(
(entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
links.forEach(link => {
link.style.color = '';
if (link.getAttribute('href') === `#${entry.target.id}`) {
link.style.color = 'var(--lavender)';
}
});
}
});
},
{ threshold: 0.4 }
);
sections.forEach(s => sectionObserver.observe(s));
});