-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (26 loc) · 1.01 KB
/
script.js
File metadata and controls
32 lines (26 loc) · 1.01 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
function scrollAnim() {
document.getElementById("title").classList.remove("animate-bottom");
document.getElementById("title").classList.add("animate-top-out");
document.getElementById("bar").classList.remove("animate-bottom");
document.getElementById("bar").classList.add("animate-top-out");
document.getElementById("desc").classList.remove("animate-bottom");
document.getElementById("desc").classList.add("animate-top-out");
document.getElementById("btn").classList.remove("animate-bottom");
document.getElementById("btn").classList.add("animate-top-out");
}
let lastScrollY = window.scrollY;
window.addEventListener('scroll', () => {
const currentScrollY = window.scrollY;
if (currentScrollY > lastScrollY) {
scrollAnim();
}
lastScrollY = currentScrollY;
})
document.addEventListener('keydown', function(event) {
event.preventDefault();
scrollAnim();
});
document.addEventListener('touchstart', function(event) {
event.preventDefault();
scrollAnim();
});