-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
205 lines (174 loc) · 6.1 KB
/
script.js
File metadata and controls
205 lines (174 loc) · 6.1 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
// 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'
});
}
});
});
// Navbar Background on Scroll
const navbar = document.querySelector('.navbar');
let lastScroll = 0;
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
// Add shadow when scrolled
if (currentScroll > 50) {
navbar.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 0.3)';
} else {
navbar.style.boxShadow = 'none';
}
lastScroll = currentScroll;
});
// Active Navigation Link on Scroll
const sections = document.querySelectorAll('section[id]');
const navLinks = document.querySelectorAll('.nav-link');
function updateActiveLink() {
const scrollPosition = window.scrollY + 100;
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.offsetHeight;
const sectionId = section.getAttribute('id');
if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) {
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${sectionId}`) {
link.classList.add('active');
}
});
}
});
}
window.addEventListener('scroll', updateActiveLink);
// Fade-in Animation on Scroll
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);
// Observe elements for fade-in effect
const animateElements = document.querySelectorAll(
'.timeline-item, .award-item, .research-item, .experience-item, ' +
'.project-card, .skill-category, .activity-card, .contact-card'
);
animateElements.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 smooth reveal for section titles
const sectionTitles = document.querySelectorAll('.section-title');
sectionTitles.forEach(title => {
title.style.opacity = '0';
title.style.transform = 'translateY(30px)';
title.style.transition = 'opacity 0.8s ease, transform 0.8s ease';
observer.observe(title);
});
// Copyright Year Auto-Update
const footer = document.querySelector('.footer p');
if (footer) {
const currentYear = new Date().getFullYear();
footer.innerHTML = `© ${currentYear} Ahhyun Lucy Lee. All rights reserved.`;
}
// Scroll Progress Indicator (optional - can be enabled)
function createScrollProgress() {
const progressBar = document.createElement('div');
progressBar.className = 'scroll-progress';
progressBar.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 0%;
height: 3px;
background: linear-gradient(90deg, #6b1f3a, #9d5c71);
z-index: 10000;
transition: width 0.1s ease;
`;
document.body.appendChild(progressBar);
window.addEventListener('scroll', () => {
const windowHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
const scrolled = (window.scrollY / windowHeight) * 100;
progressBar.style.width = scrolled + '%';
});
}
// Uncomment the line below to enable scroll progress indicator
// createScrollProgress();
// Typing Effect for Hero Title (optional)
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();
}
// Uncomment to enable typing effect on page load
// const heroTitle = document.querySelector('.hero-title');
// if (heroTitle) {
// const originalText = heroTitle.textContent;
// window.addEventListener('load', () => {
// typeWriter(heroTitle, originalText, 80);
// });
// }
// Mobile Menu Toggle (for future mobile enhancement)
function createMobileMenu() {
const navContainer = document.querySelector('.nav-container');
const navMenu = document.querySelector('.nav-menu');
// Create hamburger button
const hamburger = document.createElement('button');
hamburger.className = 'hamburger';
hamburger.innerHTML = '<i class="fas fa-bars"></i>';
hamburger.style.cssText = `
display: none;
background: none;
border: none;
color: var(--white);
font-size: 1.5rem;
cursor: pointer;
padding: 0.5rem;
`;
// Add hamburger to nav
navContainer.appendChild(hamburger);
// Toggle menu on mobile
hamburger.addEventListener('click', () => {
navMenu.classList.toggle('active');
});
// Close menu when link is clicked
document.querySelectorAll('.nav-link').forEach(link => {
link.addEventListener('click', () => {
navMenu.classList.remove('active');
});
});
// Show/hide hamburger based on screen size
function checkScreenSize() {
if (window.innerWidth <= 768) {
hamburger.style.display = 'block';
} else {
hamburger.style.display = 'none';
navMenu.classList.remove('active');
}
}
window.addEventListener('resize', checkScreenSize);
checkScreenSize();
}
// Initialize mobile menu
createMobileMenu();
// Console message for developers
console.log('%c👋 Hello! Thanks for checking out my website!', 'color: #6b1f3a; font-size: 16px; font-weight: bold;');
console.log('%cInterested in the code? Check out the repository!', 'color: #9d5c71; font-size: 14px;');