This repository has been archived on 2025-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
Files
M6C9.de/index.pug
Michael Czechowski 6dd9ad5449 add scroll events
2024-10-14 23:02:53 +02:00

34 lines
1.2 KiB
Plaintext

doctype html
html.scroll-smooth(lang=lang)
include src/components/Head
body.font-mono.m-0.p-0
main.flex.flex-col
article(itemscope, itemtype="http://schema.org/Person")
include src/components/Title
include src/components/Professional
include src/components/Academia
include src/components/Footer
script.
const footerEl = document.querySelector("#footer");
const footerObserver = new IntersectionObserver((payload) => {
const hasScrolltedTo = payload.pop().isIntersecting;
if (hasScrolltedTo && window.hasOwnProperty("umami")) {
umami.track("scrolled to", {position: "footer", id: "footer"});
console.debug("scrolled to footer");
}
});
footerObserver.observe(footerEl);
const sections = document.querySelectorAll("section");
const sectionObserver = (id) =>
new IntersectionObserver((payload) => {
const hasScrolltedTo = payload.pop().isIntersecting;
if (hasScrolltedTo && window.hasOwnProperty("umami")) {
umami.track("scrolled to", {position: "section", id});
console.debug("scrolled to section with id", id);
}
});
sections.forEach((section) => sectionObserver(section.id).observe(section));