RSCC-Page/public/floaties.js

25 lines
521 B
JavaScript
Raw Normal View History

2025-03-04 04:23:12 +01:00
document.addEventListener("DOMContentLoaded", () => {
const floaties = document.getElementById("floaties");
if (!floaties) return;
let lastScrollY = 0;
const handleScroll = () => {
const currentScrollY = window.scrollY;
if (currentScrollY > lastScrollY) {
setTimeout(() => {
floaties.classList.add("hidden");
}, 300);
} else {
setTimeout(() => {
floaties.classList.remove("hidden");
}, 400);
}
lastScrollY = currentScrollY;
};
window.addEventListener("scroll", handleScroll);
});