-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
164 lines (142 loc) · 4.53 KB
/
script.js
File metadata and controls
164 lines (142 loc) · 4.53 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
// Smooth scrolling for navigation links
document.querySelectorAll('nav 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'
});
}
});
});
// Section indicator functionality
const sections = document.querySelectorAll('section');
const indicators = document.querySelectorAll('.indicator');
function updateActiveSection() {
const scrollPosition = window.scrollY + window.innerHeight / 2;
sections.forEach((section, index) => {
const sectionTop = section.offsetTop;
const sectionBottom = sectionTop + section.offsetHeight;
if (scrollPosition >= sectionTop && scrollPosition < sectionBottom) {
indicators.forEach(ind => ind.classList.remove('active'));
if (indicators[index]) {
indicators[index].classList.add('active');
}
// Update navigation active state
document.querySelectorAll('nav a').forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${section.id}`) {
link.classList.add('active');
}
});
}
});
}
// Create section indicators dynamically
function createSectionIndicators() {
const indicatorContainer = document.querySelector('.section-indicator');
if (!indicatorContainer) return;
// Clear existing indicators
indicatorContainer.innerHTML = '';
// Add the line
const line = document.createElement('div');
line.style.cssText = `
content: '';
width: 2px;
height: 100px;
background: rgba(0, 255, 255, 0.3);
border-radius: 1px;
position: relative;
`;
indicatorContainer.appendChild(line);
// Add indicators for each section
sections.forEach((section, index) => {
const indicator = document.createElement('div');
indicator.className = 'indicator';
indicator.addEventListener('click', () => {
section.scrollIntoView({ behavior: 'smooth', block: 'start' });
});
indicatorContainer.appendChild(indicator);
});
}
// Intersection Observer for 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 animations to sections
document.querySelectorAll('section').forEach(section => {
section.style.opacity = '0';
section.style.transform = 'translateY(30px)';
section.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(section);
});
// Typing effect for terminal
function typeWriter(element, text, speed = 50) {
let i = 0;
element.innerHTML = '';
function type() {
if (i < text.length) {
element.innerHTML += text.charAt(i);
i++;
setTimeout(type, speed);
}
}
type();
}
// Apply typing effect to terminal lines
document.addEventListener('DOMContentLoaded', () => {
const terminalLines = document.querySelectorAll('.terminal-line');
terminalLines.forEach((line, index) => {
setTimeout(() => {
typeWriter(line, line.textContent, 30);
}, index * 500);
});
});
// Parallax effect for floating icons
function parallaxIcons() {
const icons = document.querySelectorAll('.icon');
const scrolled = window.pageYOffset;
const rate = scrolled * -0.5;
icons.forEach((icon, index) => {
const speed = (index + 1) * 0.1;
icon.style.transform = `translateY(${rate * speed}px)`;
});
}
// Hover effects for skill items
document.querySelectorAll('.skill-item').forEach(item => {
item.addEventListener('mouseenter', () => {
item.style.transform = 'translateY(-10px) scale(1.05)';
});
item.addEventListener('mouseleave', () => {
item.style.transform = 'translateY(0) scale(1)';
});
});
// Form submission handling
document.querySelector('.contact-form')?.addEventListener('submit', (e) => {
e.preventDefault();
// Add your form submission logic here
alert('Thank you for your message! I\'ll get back to you soon.');
});
// Initialize everything when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
createSectionIndicators();
updateActiveSection();
});
// Update active section on scroll
window.addEventListener('scroll', () => {
updateActiveSection();
parallaxIcons();
});
// Resize handler
window.addEventListener('resize', createSectionIndicators);