stylescape
Version:
Stylescape is a visual identity framework developed by Scape Agency.
40 lines • 1.53 kB
JavaScript
export class VerticalScrollManager {
constructor() {
this.scrollThreshold = 100;
this.scrollOffset = -100;
this.buttonUp = document.getElementById("cover_arrow--up");
this.buttonDown = document.getElementById("content_cover_arrow");
if (this.buttonUp) {
this.buttonUp.addEventListener("click", this.scrollToContentTop.bind(this));
window.addEventListener("scroll", this.updateUpButtonVisibility.bind(this));
this.updateUpButtonVisibility();
}
if (this.buttonDown) {
this.buttonDown.addEventListener("click", this.scrollToMainSection.bind(this));
}
}
scrollToContentTop() {
const element = document.getElementById("content_cover");
if (element) {
const top = element.getBoundingClientRect().top + window.pageYOffset;
window.scrollTo({ top, behavior: "smooth" });
}
}
scrollToMainSection() {
const element = document.getElementById("main");
if (element) {
const top = element.getBoundingClientRect().top +
window.pageYOffset +
this.scrollOffset;
window.scrollTo({ top, behavior: "smooth" });
}
}
updateUpButtonVisibility() {
if (!this.buttonUp)
return;
this.buttonUp.style.display =
window.scrollY > this.scrollThreshold ? "block" : "none";
}
}
new VerticalScrollManager();
//# sourceMappingURL=VerticalScrollManager.js.map