nav via Controller.add('content') + Activity.active() guard (Shikimori pattern); arrows + enter/back

This commit is contained in:
Hermes committed 2026-08-08 18:34:05 +02:00
1 parent b04b6aee9f
commit 0d24e24168
1 file changed
+35 -5
+35 -5
View File
@@ -79,16 +79,46 @@
body = b;
};
// Wire up keyboard/remote navigation using native Lampa Controller.
// Wire up keyboard/remote navigation (pattern from Shikimori plugin).
this.start = function () {
if (Lampa.Activity.active().activity !== this.activity) return;
if (!grid) return;
var cards = grid.find('.card.selector');
if (!cards.length) return;
// Native collection navigation: Lampa handles up/down/left/right and
// fires "hover:enter" on the focused .selector when OK/Enter is pressed.
Lampa.Controller.collectionSet(grid);
Lampa.Controller.collectionFocus(cards[0], grid);
Lampa.Controller.add('content', {
toggle: function () {
Lampa.Controller.collectionSet(grid);
Lampa.Controller.collectionFocus(cards[0], grid);
},
right: function () {
Navigator.move('right');
},
left: function () {
if (Navigator.canmove('left')) Navigator.move('left');
else Lampa.Controller.toggle('menu');
},
up: function () {
Navigator.move('up');
},
down: function () {
Navigator.move('down');
},
enter: function () {
var el = grid.find('.card.selector.focus')[0] || cards[0];
if (!el) return;
var id = $(el).attr('data-id');
var m = comp._movies ? comp._movies.find(function (x) { return x.id === id; }) : null;
if (m) openMovie(m);
},
back: function () {
Lampa.Activity.back();
},
gone: function () {
Lampa.Controller.clear('content');
}
});
Lampa.Controller.toggle('content');
};
this.render = function () {