catalog start(): register Controller driving Navigator over Scroll cards; focus once
This commit is contained in:
1 parent
747b4b2daa
commit
bba71d11bf
1 file changed
+22
-3
@@ -135,10 +135,29 @@
|
|||||||
return html;
|
return html;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Required by ActivitySlide contract. Navigation/focus/scroll are handled by
|
// Required by ActivitySlide contract. Scroll (created in create()) owns the
|
||||||
// the native Lampa.Scroll (it registers its own Controller and auto-scrolls).
|
// auto-scroll; we register a Controller that drives Navigator over the cards.
|
||||||
// Back (Escape / remote) is handled via the keydown listener in create().
|
// Focus is set on the first card only once (no reset on re-toggle).
|
||||||
this.start = function () {
|
this.start = function () {
|
||||||
|
var started = false;
|
||||||
|
Lampa.Controller.add('content', {
|
||||||
|
toggle: function () {
|
||||||
|
var wrap = $('.mymovies');
|
||||||
|
var cards = wrap.find('.card.selector');
|
||||||
|
if (!cards.length) return;
|
||||||
|
Lampa.Controller.collectionSet(wrap);
|
||||||
|
if (!started) {
|
||||||
|
started = true;
|
||||||
|
Lampa.Controller.collectionFocus(cards[0], wrap);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
left: function () { if (Navigator.canmove('left')) Navigator.move('left'); else Lampa.Controller.toggle('menu'); },
|
||||||
|
right: function () { Navigator.move('right'); },
|
||||||
|
up: function () { Navigator.move('up'); },
|
||||||
|
down: function () { Navigator.move('down'); },
|
||||||
|
back: function () { Lampa.Activity.backward(); }
|
||||||
|
});
|
||||||
|
Lampa.Controller.toggle('content');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Build each card and append through the native Scroll (handles focus + scroll).
|
// Build each card and append through the native Scroll (handles focus + scroll).
|
||||||
|
|||||||
Reference in new issue
Block a user