add 'moves'
This commit is contained in:
16
main.js
16
main.js
@@ -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.
|
||||
Reference in New Issue
Block a user