use native collection nav (arrows + hover:enter on Enter), drop custom Controller
This commit is contained in:
1 parent
85d8f32f37
commit
66de82496c
1 file changed
+2
-25
@@ -85,33 +85,10 @@
|
||||
var cards = grid.find('.card.selector');
|
||||
if (!cards.length) return;
|
||||
|
||||
// Native collection navigation: Lampa handles up/down/left/right
|
||||
// over .selector elements automatically once the collection is set.
|
||||
// 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);
|
||||
|
||||
// Custom controller only for enter/back while this screen is active.
|
||||
Lampa.Controller.add('mymovies', {
|
||||
toggle: function () {
|
||||
var focused = grid.find('.card.selector.focus')[0] || cards[0];
|
||||
Lampa.Controller.collectionFocus(focused, grid);
|
||||
},
|
||||
enter: function () {
|
||||
var el = grid.find('.card.selector.focus')[0] || cards[0];
|
||||
if (el) {
|
||||
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('mymovies');
|
||||
}
|
||||
});
|
||||
Lampa.Controller.toggle('mymovies');
|
||||
};
|
||||
|
||||
this.render = function () {
|
||||
|
||||
Reference in new issue
Block a user