-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
127 lines (110 loc) · 3.26 KB
/
script.js
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
// Smooth scroll for navigation links
document.querySelectorAll('nav a').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const section = document.querySelector(this.getAttribute('href'));
section.scrollIntoView({ behavior: 'smooth' });
});
});
// Intersection Observer for fade-in animations
const observerOptions = {
threshold: 0.25,
rootMargin: "0px"
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe all sections and project cards
document.querySelectorAll('section, .project-card').forEach((el) => {
el.classList.add('opacity-0');
observer.observe(el);
});
// Typing effect for header
function typeWriter(element, text, speed = 100) {
let i = 0;
element.innerHTML = '';
function type() {
if (i < text.length) {
element.innerHTML += text.charAt(i);
i++;
setTimeout(type, speed);
}
}
type();
}
// Initialize typing effect
window.addEventListener('load', () => {
const header = document.querySelector('header h1');
const originalText = header.innerText;
typeWriter(header, originalText);
});
// Skill bars animation
document.querySelectorAll('.skill-item').forEach(item => {
item.addEventListener('mouseenter', () => {
item.style.transform = 'scale(1.05)';
item.style.boxShadow = '0 0 15px rgba(0, 255, 157, 0.5)';
});
item.addEventListener('mouseleave', () => {
item.style.transform = 'scale(1)';
item.style.boxShadow = 'none';
});
});
// Project cards hover effect
document.querySelectorAll('.project-card').forEach(card => {
card.addEventListener('mouseenter', () => {
card.style.transform = 'translateY(-10px)';
});
card.addEventListener('mouseleave', () => {
card.style.transform = 'translateY(0)';
});
});
// Particle effect in background
function createParticle() {
const particle = document.createElement('div');
particle.className = 'particle';
particle.style.left = Math.random() * 100 + 'vw';
particle.style.animationDuration = Math.random() * 3 + 2 + 's';
document.body.appendChild(particle);
setTimeout(() => {
particle.remove();
}, 5000);
}
// Create particles periodically
setInterval(createParticle, 300);
// Add corresponding CSS for animations
const style = document.createElement('style');
style.textContent = `
.opacity-0 {
opacity: 0;
transform: translateY(20px);
transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.fade-in {
opacity: 1;
transform: translateY(0);
}
.particle {
position: fixed;
width: 2px;
height: 2px;
background: rgba(0, 255, 157, 0.5);
pointer-events: none;
animation: float linear infinite;
}
@keyframes float {
0% {
transform: translateY(100vh);
opacity: 1;
}
100% {
transform: translateY(-100vh);
opacity: 0;
}
}
`;
document.head.appendChild(style);