-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
114 lines (91 loc) · 3.55 KB
/
Copy pathscript.js
File metadata and controls
114 lines (91 loc) · 3.55 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
document.getElementById('year').textContent = new Date().getFullYear();
const themeToggle = document.getElementById('themeToggle');
const currentTheme = localStorage.getItem('portfolio_theme') || 'dark';
if (currentTheme === 'dark') {
document.body.classList.add('dark-mode');
themeToggle.textContent = '☀️';
} else {
document.body.classList.remove('dark-mode');
themeToggle.textContent = '🌙';
}
themeToggle.addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
if (document.body.classList.contains('dark-mode')) {
themeToggle.textContent = '☀️';
localStorage.setItem('portfolio_theme', 'dark');
} else {
themeToggle.textContent = '🌙';
localStorage.setItem('portfolio_theme', 'light');
}
});
const nav = document.getElementById('navbar');
const toggle = document.getElementById('navToggle');
const links = document.getElementById('navLinks');
toggle.addEventListener('click', () => {
links.classList.toggle('open');
});
const navAnchors = links.querySelectorAll('a');
navAnchors.forEach(a => {
a.addEventListener('click', (e) => {
links.classList.remove('open');
navAnchors.forEach(link => link.classList.remove('nav-cta'));
e.currentTarget.classList.add('nav-cta');
});
});
const reveals = document.querySelectorAll('.reveal');
const observer = new IntersectionObserver((entries) => {
entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('visible'); } });
}, { threshold: 0.1 });
reveals.forEach(el => observer.observe(el));
const progressBar = document.getElementById('scroll-progress');
const sections = document.querySelectorAll('section[id]');
const allNavLinks = document.querySelectorAll('.nav-links a');
let scrollFrameRequested = false;
let activeSection = '';
const updateScrollState = () => {
scrollFrameRequested = false;
const scrollTop = window.scrollY;
const docHeight = document.documentElement.scrollHeight - window.innerHeight;
const progress = docHeight > 0 ? (scrollTop / docHeight) * 100 : 0;
progressBar.style.transform = `scaleX(${progress / 100})`;
nav.classList.toggle('scrolled', scrollTop > 50);
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop - 120;
if (scrollTop >= sectionTop) {
current = section.getAttribute('id');
}
});
if (current !== activeSection) {
activeSection = current;
allNavLinks.forEach(link => {
link.classList.toggle('nav-active', link.getAttribute('href') === '#' + current);
});
}
};
const requestScrollUpdate = () => {
if (!scrollFrameRequested) {
scrollFrameRequested = true;
requestAnimationFrame(updateScrollState);
}
};
window.addEventListener('scroll', requestScrollUpdate, { passive: true });
window.addEventListener('resize', requestScrollUpdate, { passive: true });
requestScrollUpdate();
const dynamicWord = document.getElementById('dynamic-word');
if (dynamicWord) {
const words = ["creative", "scalable", "modern", "powerful", "AI-driven", "intelligent"];
let wordIndex = 0;
setInterval(() => {
dynamicWord.style.opacity = '0';
setTimeout(() => {
dynamicWord.textContent = words[wordIndex];
dynamicWord.style.opacity = '1';
wordIndex = (wordIndex + 1) % words.length;
}, 400);
}, 2500);
}
const loader = document.getElementById('loader');
if (loader) {
loader.addEventListener('animationend', () => loader.remove(), { once: true });
}