Skip to content

Instantly share code, notes, and snippets.

@wpeasy
Created April 8, 2025 12:35
Show Gist options
  • Save wpeasy/66995b6b153edd8142dd4646df41cd19 to your computer and use it in GitHub Desktop.
Save wpeasy/66995b6b153edd8142dd4646df41cd19 to your computer and use it in GitHub Desktop.
Bricks Dynamic Header Variable for AT Framework
/*
This script uodates the variable "--at-header-height" to the height of the Bricks Header dynamically.
*/
(() => {
const setHeaderHeightVar = () => {
const header = document.querySelector("#brx-header");
if (header) {
const height = header.offsetHeight;
document.body.style.setProperty(
"--at-header-height",
`${height}px`
);
}
};
// Run on load
window.addEventListener("DOMContentLoaded", setHeaderHeightVar);
// Run on resize
window.addEventListener("resize", setHeaderHeightVar);
//Init on load
setHeaderHeightVar();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment