FEAT: Created the dymanic title page.

This commit is contained in:
MajorDroolz
2022-12-16 03:29:37 -05:00
parent af212f4e21
commit 41885de1d6
4 changed files with 432 additions and 0 deletions

52
home/index.js Normal file
View File

@@ -0,0 +1,52 @@
let menuOpen = true;
function calcScroll() {
const scroll = window.scrollY;
const vh = window.innerHeight / 100;
const title = document.getElementById("title-page");
if (title == null) return;
title.style.setProperty("--scroll", Math.min(1, scroll / (77.5 * vh)));
}
function openMenu() {
const menu = document.getElementById("menu-modal");
if (menu == null) return;
requestAnimationFrame(() => menuOpen = false);
menu.showModal();
}
function closeMenu() {
const menu = document.getElementById("menu-modal");
if (menu == null) return;
requestAnimationFrame(() => menuOpen = true);
menu.close();
}
function main() {
document.body.addEventListener('wheel', preventScroll, { passive: false });
document.body.addEventListener('touchmove', preventScroll, { passive: false });
window.addEventListener("scroll", () => requestAnimationFrame(calcScroll));
const menu = document.getElementById("menu-modal");
if (menu) {
menu.addEventListener("click", clickMenuModal);
menu.addEventListener("touchstart", clickMenuModal);
}
}
function clickMenuModal(e) {
const menu = document.getElementById("menu-modal");
if (menu == null || e.target != menu) return;
closeMenu();
}
function preventScroll(e) {
if (menuOpen) return;
e.preventDefault();
e.stopPropagation();
return false;
}
window.onload = main;