-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
96 lines (87 loc) · 3.04 KB
/
script.js
File metadata and controls
96 lines (87 loc) · 3.04 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
// 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'
});
}
});
});
// Navbar background on scroll
window.addEventListener('scroll', () => {
const navbar = document.querySelector('.navbar');
if (window.scrollY > 50) {
navbar.style.background = 'rgba(10, 14, 39, 0.95)';
} else {
navbar.style.background = 'rgba(10, 14, 39, 0.9)';
}
});
// Intersection Observer for fade-in animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Apply fade-in to sections
document.querySelectorAll('.skill-category, .portfolio-card, .contact-card').forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(20px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});
// Add particle effect to background (optional - lightweight)
function createParticles() {
const bg = document.querySelector('.background-animation');
const particleCount = 30;
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(0, 217, 255, 0.5);
border-radius: 50%;
left: ${Math.random() * 100}%;
top: ${Math.random() * 100}%;
animation: float ${10 + Math.random() * 20}s linear infinite;
animation-delay: ${Math.random() * 5}s;
`;
bg.appendChild(particle);
}
}
// Add floating animation for particles
const style = document.createElement('style');
style.textContent = `
@keyframes float {
0%, 100% {
transform: translate(0, 0);
opacity: 0;
}
10%, 90% {
opacity: 0.5;
}
50% {
transform: translate(${Math.random() * 100 - 50}px, ${Math.random() * 100 - 50}px);
opacity: 0.8;
}
}
`;
document.head.appendChild(style);
// Initialize particles
createParticles();
// Console easter egg for developers
console.log('%c Hi there, developer! 👋', 'color: #00d9ff; font-size: 20px; font-weight: bold;');
console.log('%c Looking at the code? This portfolio is built with vanilla HTML, CSS, and JavaScript.', 'color: #7c3aed; font-size: 14px;');
console.log('%c Want to collaborate? Reach out at shivaniwaikar25@gmail.com', 'color: #00d9ff; font-size: 14px;');