-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
258 lines (216 loc) · 7.36 KB
/
Copy pathscript.js
File metadata and controls
258 lines (216 loc) · 7.36 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
// DOM이 로드된 후 실행
document.addEventListener('DOMContentLoaded', function() {
// 로딩 화면 제거
setTimeout(() => {
const loading = document.querySelector('.loading');
if (loading) {
loading.classList.add('hidden');
setTimeout(() => {
loading.remove();
}, 500);
}
}, 1000);
// 네비게이션 관련 기능
initNavigation();
// 스크롤 애니메이션
initScrollAnimations();
// 스킬 바 애니메이션
initSkillBars();
// 연락처 폼 제거됨
// 타이핑 효과
initTypingEffect();
});
// 네비게이션 기능 초기화
function initNavigation() {
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
const navLinks = document.querySelectorAll('.nav-link');
// 햄버거 메뉴 토글
if (hamburger) {
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navMenu.classList.toggle('active');
});
}
// 네비게이션 링크 클릭 시 메뉴 닫기
navLinks.forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
});
});
// 스크롤 시 네비게이션 스타일 변경
window.addEventListener('scroll', () => {
const navbar = document.querySelector('.navbar');
if (window.scrollY > 100) {
navbar.style.background = 'rgba(255, 255, 255, 0.98)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.15)';
} else {
navbar.style.background = 'rgba(255, 255, 255, 0.95)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)';
}
});
// 부드러운 스크롤
navLinks.forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const targetId = link.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
const offsetTop = targetSection.offsetTop - 70; // 네비게이션 높이 고려
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
}
// 스크롤 애니메이션 초기화
function initScrollAnimations() {
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, observerOptions);
// 애니메이션할 요소들 선택
const animateElements = document.querySelectorAll('.about-content, .timeline-item, .skill-category, .contact-content');
animateElements.forEach(el => {
el.classList.add('fade-in');
observer.observe(el);
});
}
// 스킬 바 애니메이션 초기화
function initSkillBars() {
const skillBars = document.querySelectorAll('.skill-progress');
const skillObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const progressBar = entry.target;
const width = progressBar.getAttribute('data-width');
setTimeout(() => {
progressBar.style.width = width + '%';
}, 200);
skillObserver.unobserve(progressBar);
}
});
}, { threshold: 0.5 });
skillBars.forEach(bar => {
skillObserver.observe(bar);
});
}
// 연락처 폼 관련 함수들 제거됨
// 타이핑 효과 초기화
function initTypingEffect() {
const heroTitle = document.querySelector('.hero-title');
if (!heroTitle) return;
const originalText = heroTitle.innerHTML;
heroTitle.innerHTML = '';
let i = 0;
const typeSpeed = 100;
function typeWriter() {
if (i < originalText.length) {
heroTitle.innerHTML += originalText.charAt(i);
i++;
setTimeout(typeWriter, typeSpeed);
}
}
// 페이지 로드 후 타이핑 시작
setTimeout(typeWriter, 500);
}
// 파티클 효과 (선택적)
function initParticles() {
const hero = document.querySelector('.hero');
if (!hero) return;
// 간단한 파티클 효과
for (let i = 0; i < 50; i++) {
createParticle(hero);
}
}
function createParticle(container) {
const particle = document.createElement('div');
particle.style.cssText = `
position: absolute;
width: 2px;
height: 2px;
background: rgba(255, 255, 255, 0.5);
border-radius: 50%;
pointer-events: none;
`;
// 랜덤 위치
particle.style.left = Math.random() * 100 + '%';
particle.style.top = Math.random() * 100 + '%';
// 애니메이션
particle.style.animation = `float ${3 + Math.random() * 4}s ease-in-out infinite`;
particle.style.animationDelay = Math.random() * 2 + 's';
container.appendChild(particle);
}
// 스크롤 진행률 표시
function initScrollProgress() {
const progressBar = document.createElement('div');
progressBar.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 0%;
height: 3px;
background: linear-gradient(90deg, #3498db, #2980b9);
z-index: 10001;
transition: width 0.1s ease;
`;
document.body.appendChild(progressBar);
window.addEventListener('scroll', () => {
const scrollTop = window.pageYOffset;
const docHeight = document.body.offsetHeight - window.innerHeight;
const scrollPercent = (scrollTop / docHeight) * 100;
progressBar.style.width = scrollPercent + '%';
});
}
// 초기화 함수들 실행
document.addEventListener('DOMContentLoaded', function() {
initScrollProgress();
initParticles();
});
// 리사이즈 이벤트 처리
window.addEventListener('resize', () => {
// 모바일 메뉴 닫기
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
if (window.innerWidth > 768) {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
}
});
// 키보드 접근성
document.addEventListener('keydown', (e) => {
// ESC 키로 모바일 메뉴 닫기
if (e.key === 'Escape') {
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
hamburger.classList.remove('active');
navMenu.classList.remove('active');
}
});
// 성능 최적화를 위한 디바운스 함수
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// 스크롤 이벤트 최적화
const optimizedScrollHandler = debounce(() => {
// 스크롤 관련 로직
}, 10);
window.addEventListener('scroll', optimizedScrollHandler);