Add a basic scroll indicator

This commit is contained in:
Jake Howard 2023-10-15 22:29:40 +01:00
parent c94871008b
commit fc3704a97a
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 34 additions and 0 deletions

View file

@ -1,6 +1,17 @@
require("lite-youtube-embed");
const GLightbox = require("glightbox");
const SCROLL_INDICATOR = document.getElementById("scroll-indicator");
const CONTENT = document.querySelector(".container.content");
window.addEventListener("load", () => {
GLightbox({});
});
window.addEventListener("scroll", () => {
const winScroll =
document.body.scrollTop || document.documentElement.scrollTop;
const height = CONTENT.getBoundingClientRect().height;
const scrolled = Math.min((winScroll / height) * 100, 100);
SCROLL_INDICATOR.style.width = `${scrolled}%`;
});

View file

@ -95,6 +95,10 @@ section.hero {
padding-bottom: unset;
}
.columns {
margin-bottom: unset !important;
}
nav.breadcrumb {
margin-bottom: 0 !important;
}
@ -121,6 +125,21 @@ section.hero {
box-shadow: $shadow;
}
}
.scroll-indicator-container {
height: 5px;
#scroll-indicator {
transition-duration: 0.5s;
transition-property: background-color;
height: 100%;
width: 50%;
}
}
&.stuck #scroll-indicator {
background-color: $primary;
}
}
#view-restriction-banner {

View file

@ -68,6 +68,10 @@
</div>
</div>
</div>
<div class="scroll-indicator-container">
<div id="scroll-indicator"></div>
</div>
</section>
{% block pre_content %}{% endblock %}