-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
301 lines (257 loc) · 9.21 KB
/
script.js
File metadata and controls
301 lines (257 loc) · 9.21 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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
// Scroll Progress Indicator
function updateScrollProgress() {
const scrollProgress = document.getElementById('scrollProgress');
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
const scrollHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
const scrollPercentage = (scrollTop / scrollHeight) * 100;
scrollProgress.style.width = scrollPercentage + '%';
}
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Intersection Observer for animations
const observerOptions = {
threshold: 0.2,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate');
}
});
}, observerOptions);
// Dynamic navbar background on scroll
let lastScrollY = window.scrollY;
function updateNavbar() {
const navbar = document.querySelector('.navbar');
const currentScrollY = window.scrollY;
if (currentScrollY > 100) {
navbar.style.background = 'rgba(15, 15, 35, 0.98)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.3)';
} else {
navbar.style.background = 'rgba(15, 15, 35, 0.95)';
navbar.style.boxShadow = 'none';
}
// Hide/show navbar on scroll
if (currentScrollY > lastScrollY && currentScrollY > 200) {
navbar.style.transform = 'translateY(-100%)';
} else {
navbar.style.transform = 'translateY(0)';
}
lastScrollY = currentScrollY;
}
// Particle effect for hero section
function createParticles() {
const hero = document.querySelector('.hero');
const particleCount = 50;
for (let i = 0; i < particleCount; i++) {
const particle = document.createElement('div');
particle.className = 'particle';
particle.style.cssText = `
position: absolute;
width: 2px;
height: 2px;
background: rgba(102, 126, 234, 0.6);
border-radius: 50%;
left: ${Math.random() * 100}%;
top: ${Math.random() * 100}%;
animation: particleFloat ${3 + Math.random() * 4}s linear infinite;
animation-delay: ${Math.random() * 5}s;
`;
hero.appendChild(particle);
}
}
// Typing effect for hero subtitle
function typeWriter(element, text, speed = 25) {
element.textContent = '';
element.style.opacity = '1';
let i = 0;
function type() {
if (i < text.length) {
element.textContent += text.charAt(i);
i++;
setTimeout(type, speed);
}
}
setTimeout(type, 1000); // Start after title animation
}
// Skill bars animation
function animateSkillBars() {
const skillCategories = document.querySelectorAll('.skill-category');
skillCategories.forEach(category => {
const tags = category.querySelectorAll('.skill-tag');
tags.forEach((tag, index) => {
tag.style.opacity = '0';
tag.style.transform = 'translateY(20px)';
setTimeout(() => {
tag.style.transition = 'all 0.5s ease';
tag.style.opacity = '1';
tag.style.transform = 'translateY(0)';
}, index * 100);
});
});
}
// Hover effects for cards
function addHoverEffects() {
const cards = document.querySelectorAll('.experience-content, .skill-category, .project-card');
cards.forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-10px) scale(1.02)';
this.style.boxShadow = '0 25px 50px rgba(102, 126, 234, 0.3)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
this.style.boxShadow = 'none';
});
});
}
// Initialize all effects
window.addEventListener('scroll', () => {
updateScrollProgress();
updateNavbar();
});
// Initialize everything when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
// Observe elements for animation
const animatedElements = document.querySelectorAll(
'.section-title, .about-text, .experience-item, .skill-category, .project-card'
);
animatedElements.forEach(el => observer.observe(el));
// Add staggered animation for skill categories and project cards
const skillCategories = document.querySelectorAll('.skill-category');
skillCategories.forEach((category, index) => {
category.style.transitionDelay = `${index * 0.2}s`;
});
const projectCards = document.querySelectorAll('.project-card');
projectCards.forEach((card, index) => {
card.style.transitionDelay = `${index * 0.3}s`;
});
const experienceItems = document.querySelectorAll('.experience-item');
experienceItems.forEach((item, index) => {
item.style.transitionDelay = `${index * 0.4}s`;
});
// Start typing effect for hero subtitle
const heroSubtitle = document.querySelector('.hero-subtitle');
const originalText = heroSubtitle.textContent;
typeWriter(heroSubtitle, originalText);
// Create particles
createParticles();
// Add hover effects
addHoverEffects();
// Animate skill bars when skills section is visible
const skillsSection = document.getElementById('skills');
const skillsObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
setTimeout(animateSkillBars, 500);
skillsObserver.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
skillsObserver.observe(skillsSection);
});
// Add some interactive cursor effect
document.addEventListener('mousemove', (e) => {
const cursor = document.querySelector('.cursor');
if (!cursor) {
const cursorElement = document.createElement('div');
cursorElement.className = 'cursor';
cursorElement.style.cssText = `
position: fixed;
width: 20px;
height: 20px;
background: radial-gradient(circle, rgba(102, 126, 234, 0.8), transparent);
border-radius: 50%;
pointer-events: none;
z-index: 9999;
transition: all 0.1s ease;
`;
document.body.appendChild(cursorElement);
}
document.querySelector('.cursor').style.left = e.clientX - 10 + 'px';
document.querySelector('.cursor').style.top = e.clientY - 10 + 'px';
});
// Add click ripple effect
document.addEventListener('click', (e) => {
const ripple = document.createElement('div');
ripple.style.cssText = `
position: absolute;
border-radius: 50%;
background: rgba(102, 126, 234, 0.6);
transform: scale(0);
animation: ripple 0.6s linear;
left: ${e.clientX - 25}px;
top: ${e.clientY - 25}px;
width: 50px;
height: 50px;
pointer-events: none;
z-index: 9999;
`;
document.body.appendChild(ripple);
setTimeout(() => {
ripple.remove();
}, 600);
});
// Mobile menu toggle (for future enhancement)
function toggleMobileMenu() {
const navLinks = document.querySelector('.nav-links');
navLinks.classList.toggle('active');
}
// Add mobile menu button functionality if needed
const createMobileMenuButton = () => {
const navbar = document.querySelector('.nav-content');
const mobileMenuBtn = document.createElement('button');
mobileMenuBtn.className = 'mobile-menu-btn';
mobileMenuBtn.innerHTML = '<i class="fas fa-bars"></i>';
mobileMenuBtn.style.cssText = `
display: none;
background: none;
border: none;
color: white;
font-size: 1.5rem;
cursor: pointer;
`;
// Show mobile menu button on small screens
const mediaQuery = window.matchMedia('(max-width: 768px)');
const handleMediaQuery = (e) => {
if (e.matches) {
mobileMenuBtn.style.display = 'block';
navbar.appendChild(mobileMenuBtn);
} else {
mobileMenuBtn.style.display = 'none';
}
};
mediaQuery.addListener(handleMediaQuery);
handleMediaQuery(mediaQuery);
mobileMenuBtn.addEventListener('click', toggleMobileMenu);
};
// Initialize mobile menu
document.addEventListener('DOMContentLoaded', createMobileMenuButton);
// Add loading animation
window.addEventListener('load', function() {
document.body.classList.add('loaded');
});
// Performance optimization - throttle scroll events
let ticking = false;
function requestTick() {
if (!ticking) {
requestAnimationFrame(() => {
updateScrollProgress();
updateNavbar();
ticking = false;
});
ticking = true;
}
}
window.addEventListener('scroll', requestTick);