-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
435 lines (367 loc) · 12.6 KB
/
script.js
File metadata and controls
435 lines (367 loc) · 12.6 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
// Three.js 3D Background
let scene, camera, renderer, particles, particleGeometry, particleMaterial;
function init3DBackground() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
camera.position.z = 5;
renderer = new THREE.WebGLRenderer({
canvas: document.getElementById('bg-canvas'),
alpha: true,
antialias: true
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
// Create particles
const particleCount = 2000;
particleGeometry = new THREE.BufferGeometry();
const positions = new Float32Array(particleCount * 3);
const colors = new Float32Array(particleCount * 3);
for (let i = 0; i < particleCount * 3; i += 3) {
positions[i] = (Math.random() - 0.5) * 50;
positions[i + 1] = (Math.random() - 0.5) * 50;
positions[i + 2] = (Math.random() - 0.5) * 50;
// Gradient colors
const color = new THREE.Color();
color.setHSL(0.6 + Math.random() * 0.2, 0.8, 0.6);
colors[i] = color.r;
colors[i + 1] = color.g;
colors[i + 2] = color.b;
}
particleGeometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
particleGeometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
particleMaterial = new THREE.PointsMaterial({
size: 0.05,
vertexColors: true,
blending: THREE.AdditiveBlending,
transparent: true,
opacity: 0.8
});
particles = new THREE.Points(particleGeometry, particleMaterial);
scene.add(particles);
// Add ambient light
const ambientLight = new THREE.AmbientLight(0x6366f1, 0.5);
scene.add(ambientLight);
// Add rotating geometric shapes
createFloatingShapes();
animate3D();
}
function createFloatingShapes() {
// Torus
const torusGeometry = new THREE.TorusGeometry(2, 0.5, 16, 100);
const torusMaterial = new THREE.MeshStandardMaterial({
color: 0x6366f1,
wireframe: true,
transparent: true,
opacity: 0.3
});
const torus = new THREE.Mesh(torusGeometry, torusMaterial);
torus.position.set(-8, 5, -10);
scene.add(torus);
// Icosahedron
const icoGeometry = new THREE.IcosahedronGeometry(1.5, 0);
const icoMaterial = new THREE.MeshStandardMaterial({
color: 0x8b5cf6,
wireframe: true,
transparent: true,
opacity: 0.4
});
const icosahedron = new THREE.Mesh(icoGeometry, icoMaterial);
icosahedron.position.set(8, -5, -8);
scene.add(icosahedron);
// Store for animation
scene.userData.torus = torus;
scene.userData.icosahedron = icosahedron;
}
function animate3D() {
requestAnimationFrame(animate3D);
// Rotate particles
particles.rotation.x += 0.0002;
particles.rotation.y += 0.0003;
// Rotate shapes
if (scene.userData.torus) {
scene.userData.torus.rotation.x += 0.01;
scene.userData.torus.rotation.y += 0.01;
}
if (scene.userData.icosahedron) {
scene.userData.icosahedron.rotation.x -= 0.01;
scene.userData.icosahedron.rotation.y -= 0.01;
}
// Mouse parallax effect
if (window.mouseX !== undefined) {
camera.position.x += (window.mouseX * 0.05 - camera.position.x) * 0.05;
camera.position.y += (window.mouseY * -0.05 - camera.position.y) * 0.05;
}
renderer.render(scene, camera);
}
// Mouse tracking for parallax
window.mouseX = 0;
window.mouseY = 0;
document.addEventListener('mousemove', (event) => {
window.mouseX = (event.clientX / window.innerWidth) * 2 - 1;
window.mouseY = (event.clientY / window.innerHeight) * 2 - 1;
});
// Handle window resize
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// Typing animation for hero roles
const roles = [
"AI/ML Engineer",
"Full-Stack Developer",
"Cloud Architect",
"DevOps Enthusiast",
"Problem Solver"
];
let roleIndex = 0;
let charIndex = 0;
let isDeleting = false;
function typeRole() {
const roleElement = document.querySelector('.role-text');
const currentRole = roles[roleIndex];
if (!isDeleting) {
roleElement.textContent = currentRole.substring(0, charIndex + 1);
charIndex++;
if (charIndex === currentRole.length) {
isDeleting = true;
setTimeout(typeRole, 2000);
return;
}
} else {
roleElement.textContent = currentRole.substring(0, charIndex - 1);
charIndex--;
if (charIndex === 0) {
isDeleting = false;
roleIndex = (roleIndex + 1) % roles.length;
}
}
setTimeout(typeRole, isDeleting ? 50 : 100);
}
// Navigation scroll effect
window.addEventListener('scroll', () => {
const navbar = document.querySelector('.navbar');
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
// Update active nav link
const sections = document.querySelectorAll('.section');
const navLinks = document.querySelectorAll('.nav-link');
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (window.scrollY >= sectionTop - 200) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${current}`) {
link.classList.add('active');
}
});
});
// Smooth scroll 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'
});
}
});
});
// Hamburger menu toggle
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
hamburger.addEventListener('click', () => {
navLinks.classList.toggle('active');
hamburger.classList.toggle('active');
});
// Skill bar animation on scroll
const observerOptions = {
threshold: 0.5,
rootMargin: '0px'
};
const skillObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const skillBars = entry.target.querySelectorAll('.skill-progress');
skillBars.forEach(bar => {
const progress = bar.getAttribute('data-progress');
bar.style.width = progress + '%';
});
}
});
}, observerOptions);
const skillsSection = document.querySelector('.skills-section');
if (skillsSection) {
skillObserver.observe(skillsSection);
}
// Fade in animation on scroll
const fadeObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
document.querySelectorAll('.about-card, .project-card, .achievement-card, .skill-category').forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(30px)';
el.style.transition = 'all 0.6s ease';
fadeObserver.observe(el);
});
// 3D tilt effect for project cards
const projectCards = document.querySelectorAll('[data-tilt]');
projectCards.forEach(card => {
card.addEventListener('mousemove', (e) => {
const rect = card.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const rotateX = (y - centerY) / 10;
const rotateY = (centerX - x) / 10;
card.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale3d(1.05, 1.05, 1.05)`;
});
card.addEventListener('mouseleave', () => {
card.style.transform = 'perspective(1000px) rotateX(0) rotateY(0) scale3d(1, 1, 1)';
});
});
// Contact form handling
const contactForm = document.getElementById('contact-form');
if (contactForm) {
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
// Create success message
const successMessage = document.createElement('div');
successMessage.style.cssText = `
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 2rem 3rem;
border-radius: 15px;
box-shadow: 0 20px 60px rgba(99, 102, 241, 0.4);
z-index: 10000;
text-align: center;
font-size: 1.2rem;
font-weight: 600;
`;
successMessage.textContent = '✓ Message sent successfully!';
document.body.appendChild(successMessage);
contactForm.reset();
setTimeout(() => {
successMessage.style.opacity = '0';
successMessage.style.transition = 'opacity 0.5s ease';
setTimeout(() => successMessage.remove(), 500);
}, 3000);
});
}
// Particle interaction on mouse move
let mouseParticles = [];
function createMouseParticle(x, y) {
const particle = document.createElement('div');
particle.style.cssText = `
position: fixed;
width: 5px;
height: 5px;
background: radial-gradient(circle, #667eea, transparent);
border-radius: 50%;
pointer-events: none;
z-index: 9999;
left: ${x}px;
top: ${y}px;
animation: particleFade 1s ease-out forwards;
`;
document.body.appendChild(particle);
setTimeout(() => particle.remove(), 1000);
}
// Add CSS animation for particles
const style = document.createElement('style');
style.textContent = `
@keyframes particleFade {
to {
transform: translateY(-50px) scale(0);
opacity: 0;
}
}
`;
document.head.appendChild(style);
let particleThrottle = false;
document.addEventListener('mousemove', (e) => {
if (!particleThrottle) {
createMouseParticle(e.clientX, e.clientY);
particleThrottle = true;
setTimeout(() => particleThrottle = false, 100);
}
});
// Loading screen
window.addEventListener('load', () => {
setTimeout(() => {
const loadingScreen = document.getElementById('loading-screen');
loadingScreen.classList.add('hidden');
// Start typing animation
typeRole();
// Initialize 3D background
init3DBackground();
}, 1000);
});
// Cursor trail effect
const cursorTrail = document.createElement('div');
cursorTrail.style.cssText = `
position: fixed;
width: 20px;
height: 20px;
border: 2px solid #6366f1;
border-radius: 50%;
pointer-events: none;
z-index: 9999;
transition: transform 0.15s ease;
mix-blend-mode: difference;
`;
document.body.appendChild(cursorTrail);
document.addEventListener('mousemove', (e) => {
cursorTrail.style.left = e.clientX - 10 + 'px';
cursorTrail.style.top = e.clientY - 10 + 'px';
});
// Add hover effect to interactive elements
document.querySelectorAll('a, button, .project-card, .about-card').forEach(el => {
el.addEventListener('mouseenter', () => {
cursorTrail.style.transform = 'scale(1.5)';
cursorTrail.style.borderColor = '#ec4899';
});
el.addEventListener('mouseleave', () => {
cursorTrail.style.transform = 'scale(1)';
cursorTrail.style.borderColor = '#6366f1';
});
});
// Floating animation for hero section elements
function floatAnimation() {
const heroContent = document.querySelector('.hero-content');
if (heroContent) {
let offset = 0;
setInterval(() => {
offset += 0.5;
heroContent.style.transform = `translateY(${Math.sin(offset * 0.05) * 10}px)`;
}, 50);
}
}
floatAnimation();
console.log('%c🚀 Portfolio Loaded Successfully!', 'color: #6366f1; font-size: 20px; font-weight: bold;');
console.log('%cBuilt with ❤️ by Manisha Priya', 'color: #8b5cf6; font-size: 14px;');