add 'moves'

This commit is contained in:
Lazy Hippopotamus
2023-06-08 16:28:42 -04:00
parent 85b43d44f7
commit ee398fe778
5 changed files with 111 additions and 14 deletions

16
main.js
View File

@@ -1,3 +1,13 @@
function clamp(min, val, max) {
if (val < min) {
val = min;
}
if (val > max) {
val = max;
}
return val;
}
const scrollchecks = () => {
var el = document.getElementById("header");
el.style.backgroundPositionY = 50 + (document.documentElement.scrollTop/el.scrollHeight) / 2 * 100 + "%";
@@ -28,9 +38,13 @@ const scrollchecks = () => {
el.classList.add("scrolly-bottomhalf");
}
});
var perc = clamp(0, document.getElementById("outer").scrollTop / (window.innerHeight / 2), 1);
document.querySelector("#headin > h1").style.fontSize = 2 + 4 * (1 - perc) + "em";
document.querySelector("#links").style.opacity = perc;
};
window.addEventListener("scroll", scrollchecks);
window.addEventListener("scrollend", scrollchecks);
window.addEventListener("wheel", scrollchecks);
window.addEventListener("resize", scrollchecks);
window.addEventListener("load", scrollchecks);
window.addEventListener("load", scrollchecks);
setInterval(scrollchecks, 250); // Computers are fast and scrolling in JavaScript is dumb. Shoot me.