-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
281 lines (239 loc) · 10.9 KB
/
script.js
File metadata and controls
281 lines (239 loc) · 10.9 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/* ════════════════════════════════════════
PAGE LOADER
════════════════════════════════════════ */
window.addEventListener('load', () => {
setTimeout(() => {
document.getElementById('loader').classList.add('done');
}, 1200);
});
/* ════════════════════════════════════════
CUSTOM CURSOR
════════════════════════════════════════ */
const cur = document.getElementById('cur');
const curT = document.getElementById('curT');
let mx = 0, my = 0; // mouse position
let tx = 0, ty = 0; // trail position (lagged)
// Move main cursor instantly with mouse
document.addEventListener('mousemove', e => {
mx = e.clientX;
my = e.clientY;
cur.style.left = mx + 'px';
cur.style.top = my + 'px';
});
// Laggy trail using RAF loop
(function loop() {
tx += (mx - tx) * 0.18;
ty += (my - ty) * 0.18;
curT.style.left = tx + 'px';
curT.style.top = ty + 'px';
requestAnimationFrame(loop);
})();
// Morph cursor to pill on interactive elements
document.querySelectorAll('a, button, .pill, .pj-tg, .edp-pill').forEach(el => {
el.addEventListener('mouseenter', () => cur.classList.add('pill'));
el.addEventListener('mouseleave', () => cur.classList.remove('pill'));
});
/* ════════════════════════════════════════
PARALLAX ORBS — Mouse Move
════════════════════════════════════════ */
document.addEventListener('mousemove', e => {
const cx = (e.clientX / window.innerWidth - 0.5);
const cy = (e.clientY / window.innerHeight - 0.5);
document.querySelectorAll('.orb').forEach((orb, i) => {
const speed = ((i % 5) + 1) * 6;
const rect = orb.closest('section')?.getBoundingClientRect();
// Only move orbs in visible sections
if (rect && rect.top < window.innerHeight && rect.bottom > 0) {
orb.style.transform = `translate(${cx * speed}px, ${cy * speed}px)`;
}
});
});
/* ════════════════════════════════════════
SCROLL REVEAL
════════════════════════════════════════ */
const revealObserver = new IntersectionObserver((entries) => {
entries.forEach((entry, i) => {
if (entry.isIntersecting) {
setTimeout(() => entry.target.classList.add('vis'), i * 80);
}
});
}, { threshold: 0.08 });
document.querySelectorAll('.rev, .rev-l, .rev-r, .rev-s').forEach(el => {
revealObserver.observe(el);
});
/* ════════════════════════════════════════
SKILL BAR ANIMATION
════════════════════════════════════════ */
const skillObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
// Animate each skill bar width from 0 to its data-w value
entry.target.querySelectorAll('.sk-f').forEach(bar => {
const targetWidth = bar.dataset.w;
bar.style.width = '0';
setTimeout(() => { bar.style.width = targetWidth; }, 400);
});
skillObserver.unobserve(entry.target);
}
});
}, { threshold: 0.2 });
const skillsSection = document.getElementById('skills');
if (skillsSection) skillObserver.observe(skillsSection);
/* ════════════════════════════════════════
3D CARD TILT
════════════════════════════════════════ */
document.querySelectorAll('.tilt3d').forEach(card => {
card.addEventListener('mousemove', e => {
const rect = card.getBoundingClientRect();
const cx = (e.clientX - rect.left) / rect.width - 0.5;
const cy = (e.clientY - rect.top) / rect.height - 0.5;
card.style.transform = `perspective(600px) rotateX(${-cy * 12}deg) rotateY(${cx * 12}deg) scale(1.02)`;
});
card.addEventListener('mouseleave', () => {
card.style.transform = '';
});
});
/* ════════════════════════════════════════
MAGNETIC BUTTONS
════════════════════════════════════════ */
document.querySelectorAll('.btn-dark, .btn-soft, .btn-orange, .n-cta, .soc').forEach(btn => {
btn.addEventListener('mousemove', e => {
const rect = btn.getBoundingClientRect();
const dx = e.clientX - (rect.left + rect.width / 2);
const dy = e.clientY - (rect.top + rect.height / 2);
btn.style.transform = `translate(${dx * 0.25}px, ${dy * 0.25}px) scale(1.06)`;
});
btn.addEventListener('mouseleave', () => {
btn.style.transform = '';
});
});
/* ════════════════════════════════════════
NAV — Scroll Style Change
════════════════════════════════════════ */
window.addEventListener('scroll', () => {
const nav = document.getElementById('nav');
const scrolled = window.scrollY > 60;
nav.style.background = scrolled ? 'rgba(240,232,222,0.96)' : 'rgba(240,232,222,0.82)';
nav.style.boxShadow = scrolled
? '0 4px 24px rgba(180,140,110,0.16)'
: '0 2px 20px rgba(180,140,110,0.1)';
});
/* ════════════════════════════════════════
EXPERIENCE TABS
════════════════════════════════════════ */
const expData = [
{
co: 'Self Learning',
role: '// Frontend Development',
per: '📅 2023 – Present · Ongoing',
desc: 'Started my development journey learning HTML, CSS and JavaScript from scratch. Focused on building real-world projects to solidify concepts and gain hands-on experience.',
items: [
'Mastered core frontend technologies — HTML5, CSS3, JavaScript ES6+',
'Built responsive websites with mobile-first design approach',
'Learned React fundamentals — components, hooks, state management',
'Practiced DOM manipulation through 10+ mini JavaScript projects'
],
pills: ['HTML5', 'CSS3', 'JavaScript', 'React', 'Responsive Design']
},
{
co: 'Open Source',
role: '// GitHub Projects',
per: '📅 2024 – Present · Active',
desc: 'Actively contributing to open source by building and sharing public projects on GitHub. Exploring codebases, learning collaborative workflows, and preparing for hackathons.',
items: [
'Published 14+ repositories on GitHub covering various web projects',
'Most starred project — Coffee Website — received 3 stars and 6 forks',
'Learning how to write readable, maintainable open-source code',
'Exploring MLH programs and beginner-friendly contribution opportunities'
],
pills: ['Git', 'GitHub', 'Open Source', 'HTML', 'CSS', 'JavaScript']
},
{
co: 'Freelance / Projects',
role: '// Web Developer',
per: '📅 2024 – Present · Building',
desc: 'Working on client and personal projects to sharpen real-world development skills. Delivering responsive, performant web applications from concept to deployment.',
items: [
'Built Auraa — a fully responsive e-commerce website deployed on Netlify',
'Created Restaurant Web — open-source project with clean UI/UX',
'Designed and developed Coffee Website with modern dark theme & animations',
'Focused on clean code, performance and cross-browser compatibility'
],
pills: ['HTML', 'CSS', 'JavaScript', 'jQuery', 'Netlify', 'GitHub Pages']
}
];
/**
* Switches the active experience tab and updates the detail panel.
* @param {number} index - Index of the tab to show (0, 1, or 2)
*/
function selExp(index) {
// Toggle active class on tabs
document.querySelectorAll('.exp-tab').forEach((tab, i) => {
tab.classList.toggle('active', i === index);
});
const data = expData[index];
const panel = document.getElementById('epanel');
// Animate out
panel.style.opacity = '0';
panel.style.transform = 'translateY(14px) scale(0.97)';
setTimeout(() => {
// Build items HTML
const itemsHTML = data.items
.map(item => `<li>${item}</li>`)
.join('');
// Build pills HTML
const pillsHTML = data.pills
.map(pill => `<span class="edp-pill">${pill}</span>`)
.join('');
panel.innerHTML = `
<div class="edp-co">${data.co}</div>
<div class="edp-role">${data.role}</div>
<div class="edp-per">${data.per}</div>
<p class="edp-desc">${data.desc}</p>
<ul class="edp-ul">${itemsHTML}</ul>
<div class="edp-pills">${pillsHTML}</div>
`;
// Stagger list item animations
panel.querySelectorAll('.edp-ul li').forEach((li, j) => {
li.style.animationDelay = `${j * 0.1}s`;
});
// Animate in
panel.style.opacity = '1';
panel.style.transform = 'translateY(0) scale(1)';
}, 250);
}
// Set panel transition and show first tab by default
document.getElementById('epanel').style.transition = 'all 0.4s cubic-bezier(.23,1,.32,1)';
/* ════════════════════════════════════════
COUNTER ANIMATION — Scroll Triggered
════════════════════════════════════════ */
/**
* Animates a number from 0 to target.
* @param {HTMLElement} el - Element to update
* @param {number} target - Final number value
* @param {string} suffix - Appended suffix e.g. '+' or '%'
*/
function animateCount(el, target, suffix = '') {
let current = 0;
const duration = 1800;
const stepTime = duration / target;
const timer = setInterval(() => {
current++;
el.textContent = current + suffix;
if (current >= target) clearInterval(timer);
}, stepTime);
}
const statsObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
document.querySelectorAll('.hsv').forEach(el => {
const text = el.textContent;
if (text.includes('+')) animateCount(el, parseInt(text), '+');
else if (text.includes('%')) animateCount(el, parseInt(text), '%');
});
statsObserver.disconnect();
}
});
}, { threshold: 0.5 });
const statsEl = document.querySelector('.hc-stats');
if (statsEl) statsObserver.observe(statsEl);