« get me outta code hell

Hide items which are scrolled past in ListScrollForm - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/ui/form
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2017-12-09 11:39:29 -0400
committerFlorrie <towerofnix@gmail.com>2017-12-09 11:39:29 -0400
commit39b4468c2757d6d7a9416099b21030b09f850280 (patch)
treef2b5eb56c4430d74ac8faed09895a1b6113a93b3 /ui/form
parentdbdf9cc8f4dbc138766bf8b0ea756cbe6fd6ba32 (diff)
Hide items which are scrolled past in ListScrollForm
Diffstat (limited to 'ui/form')
-rw-r--r--ui/form/ListScrollForm.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/ui/form/ListScrollForm.js b/ui/form/ListScrollForm.js
index b23f973..7d2b083 100644
--- a/ui/form/ListScrollForm.js
+++ b/ui/form/ListScrollForm.js
@@ -20,11 +20,17 @@ module.exports = class ListScrollForm extends Form {
     // visible and we won't bother iterating over them.
     const itemsPastScroll = this.inputs.slice(this.scrollItems)
 
+    // We do need to hide them, though.
+    const itemsBeforeScroll = this.inputs.slice(0, this.scrollItems)
+    for (const item of itemsBeforeScroll) {
+      item.visible = false
+    }
+
     // This variable stores how far along the respective axis (as defined by
     // posProp) the next element should be.
     let nextPos = 0
 
-    for (let item of itemsPastScroll) {
+    for (const item of itemsPastScroll) {
       item[this.posProp] = nextPos
       nextPos += item[this.sizeProp]