keep active dir scrolled into view on keybd nav

This commit is contained in:
ed 2021-07-18 22:32:34 +02:00
parent 789724e348
commit 3e8541362a

View file

@ -1711,6 +1711,25 @@ var thegrid = (function () {
})(); })();
function tree_scrollto() {
var act = QS('#treeul a.hl');
if (!act)
return;
var ctr = ebi('tree'),
ul = act.offsetParent,
em = parseFloat(getComputedStyle(act).fontSize),
top = act.offsetTop + ul.offsetTop,
min = top - 11 * em,
max = top - (ctr.offsetHeight - 10 * em);
if (ctr.scrollTop > min)
ctr.scrollTop = Math.floor(min);
else if (ctr.scrollTop < max)
ctr.scrollTop = Math.floor(max);
}
function tree_neigh(n) { function tree_neigh(n) {
var links = QSA('#treeul li>a+a'); var links = QSA('#treeul li>a+a');
if (!links.length) { if (!links.length) {
@ -1736,6 +1755,7 @@ function tree_neigh(n) {
if (act >= links.length) if (act >= links.length)
act = 0; act = 0;
treectl.dir_cb = tree_scrollto;
links[act].click(); links[act].click();
} }