var sticky_selector = '.site-header'; var sticky_max_top = 0; window.addEventListener('scroll', function () { let lastTime = 0; return function () { const currentTime = new Date().getTime(); if (currentTime - lastTime <= 30) return; lastTime = currentTime; const el = document.querySelector(sticky_selector); if(!el) return; const offsetHeight = el.offsetHeight + 'px'; const rect = el.getBoundingClientRect(); if (rect.top >= sticky_max_top) { sticky_max_top = rect.top const root = document.querySelector(':root'); if (root && root.style) { root.style.setProperty('--header-height', offsetHeight); } } if (document.documentElement.scrollTop > sticky_max_top + 10) { el.style = 'position:fixed;top:0;z-index:1010;width:100%'; document.querySelector('#app').style = `padding-top: ${offsetHeight}`; } else { el.removeAttribute('style'); document.querySelector('#app').removeAttribute('style'); } } }()) var headerStyle = 'center';