catalog: scrollFocused driven by keydown arrows (Controller may not own arrows); keeps card visible

This commit is contained in:
Hermes committed 2026-08-08 23:01:23 +02:00
1 parent 5995ad6c3c
commit dd59e79f94
1 file changed
+15 -10
+15 -10
View File
@@ -83,6 +83,16 @@
var body;
var grid;
// Keep the focused card visible while navigating down/up (native Lampa behaviour).
function scrollFocused() {
var cont = document.querySelector('.mymovies');
var el = document.querySelector('.mymovies .card.selector.focus');
if (cont && el) {
var delta = el.getBoundingClientRect().top - cont.getBoundingClientRect().top;
cont.scrollTop += delta - 100;
}
}
this.create = function (b) {
body = b;
comp._onKey = function (e) {
@@ -90,6 +100,9 @@
e.preventDefault();
e.stopPropagation();
Lampa.Activity.backward();
} else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
// After Navigator moves focus, keep the focused card visible.
setTimeout(scrollFocused, 30);
}
};
document.addEventListener('keydown', comp._onKey, true);
@@ -147,18 +160,10 @@
},
left: function () { if (Navigator.canmove('left')) Navigator.move('left'); else Lampa.Controller.toggle('menu'); },
right: function () { Navigator.move('right'); },
up: function () { Navigator.move('up'); setTimeout(scrollFocused, 30); },
down: function () { Navigator.move('down'); setTimeout(scrollFocused, 30); },
up: function () { Navigator.move('up'); },
down: function () { Navigator.move('down'); },
back: function () { Lampa.Activity.backward(); }
});
function scrollFocused() {
var cont = document.querySelector('.mymovies');
var el = document.querySelector('.mymovies .card.selector.focus');
if (cont && el) {
var delta = el.getBoundingClientRect().top - cont.getBoundingClientRect().top;
cont.scrollTop += delta - 100;
}
}
Lampa.Controller.toggle('content');
};