This commit is contained in:
1 parent
5419d15518
commit
2a42d0245a
14 files changed
+805
-201
No files matched your search
+8
-28
@@ -1,7 +1,6 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
setupMobileNavigation();
|
||||
setupScrollAnimations();
|
||||
setupProjectFiltering();
|
||||
setupContactForm();
|
||||
setupSmoothScrollClose();
|
||||
});
|
||||
@@ -64,7 +63,14 @@ function setupSmoothScrollClose() {
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
target.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
const stickyHeader = document.querySelector(".site-header");
|
||||
const headerOffset = stickyHeader ? stickyHeader.offsetHeight + 16 : 16;
|
||||
const targetTop = target.getBoundingClientRect().top + window.scrollY - headerOffset;
|
||||
|
||||
window.scrollTo({
|
||||
top: Math.max(targetTop, 0),
|
||||
behavior: "smooth"
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -101,32 +107,6 @@ function setupScrollAnimations() {
|
||||
animatedItems.forEach((item) => observer.observe(item));
|
||||
}
|
||||
|
||||
function setupProjectFiltering() {
|
||||
const filterButtons = document.querySelectorAll("[data-filter]");
|
||||
const filterItems = document.querySelectorAll("[data-category]");
|
||||
|
||||
if (!filterButtons.length || !filterItems.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
filterButtons.forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const filterValue = button.dataset.filter;
|
||||
|
||||
filterButtons.forEach((otherButton) => {
|
||||
otherButton.classList.toggle("is-active", otherButton === button);
|
||||
otherButton.setAttribute("aria-pressed", String(otherButton === button));
|
||||
});
|
||||
|
||||
filterItems.forEach((item) => {
|
||||
const categories = (item.dataset.category || "").split(" ");
|
||||
const shouldShow = filterValue === "all" || categories.includes(filterValue);
|
||||
item.classList.toggle("is-hidden", !shouldShow);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function setupContactForm() {
|
||||
const form = document.querySelector("[data-contact-form]");
|
||||
|
||||
|
||||
Reference in new issue
Block a user