-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
36 lines (31 loc) · 1.02 KB
/
app.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
document.addEventListener('DOMContentLoaded', () => {
const pages = document.querySelectorAll('.page');
let currentPageIndex = 0; // 현재 페이지 인덱스를 추적
let isScrolling = false; // 스크롤 중인지 여부를 추적
const scrollToPage = (index) => {
window.scrollTo({
top: pages[index].offsetTop,
behavior: 'smooth'
});
currentPageIndex = index; // 현재 페이지 인덱스 업데이트
};
document.addEventListener('wheel', event => {
event.preventDefault();
if (isScrolling) return;
isScrolling = true;
if (event.deltaY > 0) {
// 아래로 스크롤
if (currentPageIndex < pages.length - 1) {
scrollToPage(currentPageIndex + 1);
}
} else {
// 위로 스크롤
if (currentPageIndex > 0) {
scrollToPage(currentPageIndex - 1);
}
}
setTimeout(() => {
isScrolling = false;
}, 1000); // 스크롤 애니메이션 시간 조정
}, { passive: false });
});