This commit is contained in:
Lazy Hippopotamus
2023-06-10 14:58:25 -04:00
parent 2097b5d597
commit d539e73f9a
4 changed files with 145 additions and 79 deletions

45
main.js
View File

@@ -39,8 +39,9 @@ const scrollchecks = () => {
}
});
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;
document.querySelector("#headin > h1").style.fontSize = 0 + 6 * (1 - perc) + "em";
//document.querySelector("#links").style.opacity = perc;
//document.querySelector("#carousel").style.opacity = perc;
};
window.addEventListener("scroll", scrollchecks);
window.addEventListener("scrollend", scrollchecks);
@@ -48,4 +49,42 @@ window.addEventListener("wheel", scrollchecks);
window.addEventListener("resize", scrollchecks);
window.addEventListener("load", scrollchecks);
window.addEventListener("touchmove", scrollchecks);
setInterval(scrollchecks, 250); // Computers are fast and scrolling in JavaScript is dumb. Shoot me.
setInterval(scrollchecks, 250); // Computers are fast and scrolling in JavaScript is dumb. Shoot me.
function main() {
requestAnimationFrame(main);
var el = document.getElementById("carousel-inner");
if (getComputedStyle(el).getPropertyValue("--do-scroll") == "yes") {
el.scrollBy({
left: 10,
top: 0,
behavior: "smooth"
});
}
if (el.scrollLeft > el.scrollWidth - window.innerWidth - (el.children[0].getBoundingClientRect().width * 3)) {
var hammer = el.children[0];
el.removeChild(hammer);
let smol = el.scrollWidth;
el.appendChild(hammer);
hammer = el.lastChild;
el.scrollBy({
left: smol - el.scrollWidth,
top: 0,
behavior: "auto"
});
}
if (el.scrollLeft < el.children[0].getBoundingClientRect().width * 3) {
var hammer = el.lastChild;
el.removeChild(hammer);
let smol = el.scrollWidth;
el.insertBefore(hammer, el.firstChild);
hammer = el.firstChild;
el.scrollBy({
left: el.scrollWidth - smol,
top: 0,
behavior: "auto"
});
}
}
main();