From ec30c595c48037d6b59013cc3f5b7a1ff96bc8c2 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 9 Jun 2018 22:50:57 -0600 Subject: [PATCH] Fix drawing like page up/down --- core/vertical_menu_view.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/core/vertical_menu_view.js b/core/vertical_menu_view.js index fe5c1203..7e8fc808 100644 --- a/core/vertical_menu_view.js +++ b/core/vertical_menu_view.js @@ -312,12 +312,31 @@ VerticalMenuView.prototype.focusNextPageItem = function() { }; VerticalMenuView.prototype.focusFirst = function() { + if(0 < this.viewWindow.top) { + this.oldDimens = Object.assign({}, this.dimens); + } this.setFocusItemIndex(0); return VerticalMenuView.super_.prototype.focusFirst.call(this); }; VerticalMenuView.prototype.focusLast = function() { - this.setFocusItemIndex(this.items.length - 1); + const index = this.items.length - 1; + + if(index > this.viewWindow.bottom) { + this.oldDimens = Object.assign({}, this.dimens); + + this.focusedItemIndex = index; + + this.viewWindow = { + top : this.focusedItemIndex, + bottom : Math.min(this.focusedItemIndex + this.maxVisibleItems, this.items.length) - 1 + }; + + this.redraw(); + } else { + this.setFocusItemIndex(index); + } + return VerticalMenuView.super_.prototype.focusLast.call(this); };