Created
April 8, 2025 12:35
-
-
Save wpeasy/66995b6b153edd8142dd4646df41cd19 to your computer and use it in GitHub Desktop.
Bricks Dynamic Header Variable for AT Framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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