weirsoe-ui.js: publish measured fixed-navbar height as --wt-nav-height
So content can clear a fixed top navbar exactly instead of guessing (CSS guesses overlapped on mobile when the bar was taller). Measured on load/resize/orientation from .navbar.is-fixed-top (or [data-wt-fixed-nav]); consumers use padding-top: calc(var(--wt-nav-height) + gap).
This commit is contained in:
@@ -182,6 +182,17 @@
|
|||||||
document.querySelectorAll('[data-wt-sortable]').forEach(initSortable);
|
document.querySelectorAll('[data-wt-sortable]').forEach(initSortable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Publish the real fixed-navbar height as --wt-nav-height so content can clear
|
||||||
|
// it exactly (CSS guesses overlap when the navbar is taller than assumed).
|
||||||
|
function setNavHeight() {
|
||||||
|
var nav = document.querySelector('[data-wt-fixed-nav], .navbar.is-fixed-top');
|
||||||
|
if (nav) document.documentElement.style.setProperty('--wt-nav-height', nav.offsetHeight + 'px');
|
||||||
|
}
|
||||||
|
setNavHeight();
|
||||||
|
window.addEventListener('load', setNavHeight);
|
||||||
|
window.addEventListener('resize', setNavHeight);
|
||||||
|
window.addEventListener('orientationchange', setNavHeight);
|
||||||
|
|
||||||
document.addEventListener('click', function (e) {
|
document.addEventListener('click', function (e) {
|
||||||
var btn = e.target.closest && e.target.closest('[data-copy-link]');
|
var btn = e.target.closest && e.target.closest('[data-copy-link]');
|
||||||
if (!btn) return;
|
if (!btn) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user