dynamic scroll offset for header bars

This commit is contained in:
Til Schmitter 2026-04-25 12:59:06 +02:00
parent 1f342bd26c
commit 40eb6271d5
2 changed files with 51 additions and 1 deletions

View file

@ -587,6 +587,10 @@ html .ayjump:focus-visible {
position: sticky;
top: .6em;
z-index: 4;
pointer-events: none;
}
#pathBar *:not(#wfp) {
pointer-events: all;
}
#wfp.shifted {
margin-left: 2em;
@ -2174,6 +2178,7 @@ html.y #tree.nowrap .ntree a+a:hover {
position: sticky;
top: 3.7em;
z-index: 3;
transition: opacity .15s;
}
.ghead .btn {
position: relative;
@ -3618,12 +3623,19 @@ html.d #treepar {
/* basically a mobile / phone layout */
#ghead.inv {
opacity: 0;
pointer-events: none;
}
#pathBar.thin {
display: block;
#path {
position: relative;
height: 1.8em;
margin: .5em 0 0 0;
top: var(--dyn-scrolloffset);
z-index: -1;
}
#wfp.shifted {
margin-left: 2.5em;
@ -3646,7 +3658,7 @@ html.e #pathBar.thin #path {
}
html:not(.e) #wrap.thin {
#ghead {
top: 7em;
top: calc(7.4em + var(--dyn-scrolloffset));
}
}
html.e #wrap.thin {
@ -4021,6 +4033,7 @@ html.ez {
html.e {
text-shadow: none;
--dyn-scrolloffset: 0 !important;
}
html.e * {
border-radius: 0 !important;

View file

@ -7393,6 +7393,34 @@ var filecolwidth = (function () {
})();
onresize100.add(filecolwidth, true);
var ows_active = false;
var lastY = 0;
var trailingY0 = 0;
function onwrapscroll () {
var newY = yscroll();
var down = newY > lastY;
var gh = ebi('ghead');
var pa = ebi('path');
var totalH = gh.offsetHeight + ebi('pathBar').offsetHeight;
if(newY > trailingY0 + totalH){
trailingY0 = newY - totalH;
clmod(gh, 'inv', true);
}
else if(newY < trailingY0)
{
trailingY0 = newY;
clmod(gh, 'inv', false);
}
else{
clmod(gh, 'inv', false);
}
document.documentElement.style.setProperty('--dyn-scrolloffset', (trailingY0 - newY) + 'px');
lastY = newY;
}
function onwidgetresize(){
var widget = ebi('widget');
var bar = ebi('pctl');
@ -7404,6 +7432,15 @@ function onwidgetresize(){
clmod(ebi('pathBar'), 'thin', thin);
clmod(ebi('wrap'), 'thin', thin);
if(thin && !ows_active){
window.addEventListener('scroll', onwrapscroll);
ows_active = true;
}
else if (!thin && ows_active){
window.removeEventListener('scroll', onwrapscroll);
ows_active = false;
}
thin = thin || IE;
var gtc = 'max-content max-content max-content ' + (thin ? '' : '20%') + ' auto max-content max-content max-content';