-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
87 lines (67 loc) · 2.29 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./styles/main.css">
<title>AskWeave - Prompt Enhancer</title>
</head>
<body class="background">
<header>
<h1>Welcome To AskWeave</h1>
</header>
<section class="container">
<div class="container__wrapper">
<div class="section container__one">
<p>One</p>
</div>
<div class="section container__two">
<p>Two</p>
</div>
<div class="section container__three">
<p>Three</p>
</div>
<div class="section container__four">
<p>Four</p>
</div>
<div class="section container__five">
<p>Five</p>
</div>
</div>
</section>
<script>
function replaceVerticalScrollByHorizontal(event) {
if (event.deltaY !== 0) {
window.scroll(window.scrollX + event.deltaY * 2, window.scrollY);
event.preventDefault();
}
}
const mediaQuery = window.matchMedia('(min-width: 770px)');
if (mediaQuery.matches) {
window.addEventListener('wheel', replaceVerticalScrollByHorizontal);
}
const sections = document.querySelectorAll('article');
let currentSection = 0;
window.addEventListener('wheel', (event) => {
// Prevent overscrolling
event.preventDefault();
if (event.deltaY > 0) {
// Scrolling down
currentSection = Math.min(currentSection + 1, sections.length - 1);
} else if (event.deltaY < 0) {
// Scrolling up
currentSection = Math.max(currentSection - 1, 0);
}
// Scroll to the next or previous section
sections[currentSection].scrollIntoView({
behavior: 'smooth',
block: 'start',
inline: 'nearest',
});
setTimeout(() => {
isScrolling = false;
}, 10000); // 500ms delay
});
</script>
</body>
</html>