diff options
author | Florrie <towerofnix@gmail.com> | 2018-08-05 13:11:28 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-08-05 13:11:28 -0300 |
commit | b3fb0187f9c02cb98d98c41c076036ee2b528455 (patch) | |
tree | 77b95efde2795a583de01fe4e19989c0cc7e03b6 | |
parent | 2b1f0b65f1f0eee5a5d621e92e7b64142df0734b (diff) |
(perf) Cache scrollItemsLength
-rw-r--r-- | ui/form/ListScrollForm.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ui/form/ListScrollForm.js b/ui/form/ListScrollForm.js index 300fed4..3f16416 100644 --- a/ui/form/ListScrollForm.js +++ b/ui/form/ListScrollForm.js @@ -62,6 +62,8 @@ module.exports = class ListScrollForm extends Form { item.visible = false } } + + delete this._scrollItemsLength } keyPressed(keyBuf) { @@ -151,8 +153,12 @@ module.exports = class ListScrollForm extends Form { } getScrollItemsLength() { - const lastInput = this.inputs[this.inputs.length - 1] - return this.getScrollPositionOfElementAtEndOfView(lastInput) + if (typeof this._scrollItemsLength === 'undefined') { + const lastInput = this.inputs[this.inputs.length - 1] + this._scrollItemsLength = this.getScrollPositionOfElementAtEndOfView(lastInput) + } + + return this._scrollItemsLength } getItemPos(item) { |