STAY UP TO DATE
Sign up for exclusive news and offers!
Sign up
We use cookies from third party services to offer you a better experience. Read about how we use cookies and how you can control them by clicking "Privacy Preferences".
// When clicking inside this gallery, activate clean-mode
document.addEventListener('click', function (e) {
if (e.target.closest('.hide-lightbox-controls a')) {
document.body.classList.add('hlc-active');
}
}, true);
// When the lightbox closes, remove clean-mode
document.addEventListener('click', function (e) {
if (e.target.closest('.ilightbox-close')) {
document.body.classList.remove('hlc-active');
}
}, true);
(function () {
const INDEX_ID = "index-1211071"; // your posts module wrapper
const TOP_OFFSET = 80; // adjust for your header height
const MIN_WIDTH = 1000; // only run on desktop
function initStickyAjaxSidebar() {
// Find the sidebar wrapper generated by Uncode Ajax Filters
const root = document.getElementById(INDEX_ID) || document;
const sidebarWrap = root.querySelector(".ajax-filter-sidebar-wrapper") ||
document.querySelector(".ajax-filter-sidebar-wrapper");
const sidebar = root.querySelector(".ajax-filter-sidebar") ||
document.querySelector(".ajax-filter-sidebar");
if (!sidebarWrap || !sidebar) return;
// Clean up any previous run
sidebar.classList.remove("js-sticky-on");
sidebar.style.position = "";
sidebar.style.top = "";
sidebar.style.width = "";
sidebar.style.left = "";
sidebar.style.zIndex = "";
sidebar.style.maxHeight = "";
sidebar.style.overflow = "";
// Measure original position relative to document
const wrapRect = sidebarWrap.getBoundingClientRect();
const startY = window.scrollY + wrapRect.top;
function onScroll() {
if (window.innerWidth < MIN_WIDTH) {
// Reset on smaller screens
sidebar.classList.remove("js-sticky-on");
sidebar.style.position = "";
sidebar.style.top = "";
sidebar.style.width = "";
sidebar.style.left = "";
sidebar.style.zIndex = "";
sidebar.style.maxHeight = "";
sidebar.style.overflow = "";
return;
}
const shouldStick = window.scrollY + TOP_OFFSET >= startY;
if (shouldStick && !sidebar.classList.contains("js-sticky-on")) {
// Lock width + left so it doesn't jump when fixed
const currentRect = sidebarWrap.getBoundingClientRect();
sidebar.classList.add("js-sticky-on");
sidebar.style.position = "fixed";
sidebar.style.top = TOP_OFFSET + "px";
sidebar.style.left = currentRect.left + "px";
sidebar.style.width = currentRect.width + "px";
sidebar.style.zIndex = "999";
} else if (!shouldStick && sidebar.classList.contains("js-sticky-on")) {
// Unstick back to normal
sidebar.classList.remove("js-sticky-on");
sidebar.style.position = "";
sidebar.style.top = "";
sidebar.style.left = "";
sidebar.style.width = "";
sidebar.style.zIndex = "";
sidebar.style.maxHeight = "";
sidebar.style.overflow = "";
} else if (shouldStick && sidebar.classList.contains("js-sticky-on")) {
// Keep aligned on resize/scroll
const currentRect = sidebarWrap.getBoundingClientRect();
sidebar.style.left = currentRect.left + "px";
sidebar.style.width = currentRect.width + "px";
}
}
window.addEventListener("scroll", onScroll, { passive: true });
window.addEventListener("resize", onScroll);
onScroll();
}
// Run after page load
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initStickyAjaxSidebar);
} else {
initStickyAjaxSidebar();
}
// Re-run after AJAX updates (Uncode filters refresh the DOM)
document.addEventListener("ajaxComplete", initStickyAjaxSidebar);
})();