diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-05-15 15:58:03 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-05-15 15:58:03 +1000 |
| commit | ddc03204e13385c31c5980e4bd55b3e193ec6138 (patch) | |
| tree | 2b6a0879dc55c70a7de19b89afbd75e09993cd61 | |
| parent | 4c9b77ea1308ef3fe72a81d888560161d19485d6 (diff) | |
| parent | e7272af4aeaf4a73d90b29c5d3d756bc8c6218b9 (diff) | |
| download | tangara-fw-ddc03204e13385c31c5980e4bd55b3e193ec6138.tar.gz | |
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
| -rw-r--r-- | lua/widgets.lua | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lua/widgets.lua b/lua/widgets.lua index bd8c84f8..0aa3e0b4 100644 --- a/lua/widgets.lua +++ b/lua/widgets.lua @@ -265,8 +265,6 @@ function widgets.InfiniteList(parent, iterator, opts) fwd_iterator:prev() end - local moving_back = false - local function add_item(item, index) if not item then return @@ -288,7 +286,7 @@ function widgets.InfiniteList(parent, iterator, opts) end btn:onevent(lvgl.EVENT.FOCUSED, function() if refreshing then return end - if this_item > last_selected and this_item - first_index > 5 then + if this_item > last_selected and this_item - first_index > 3 then -- moving forward local to_add = fwd_iterator:next() if to_add then @@ -298,18 +296,16 @@ function widgets.InfiniteList(parent, iterator, opts) end if this_item < last_selected then -- moving backward - if (last_index - first_index > 10) then + if (first_index > 0 and last_index - this_item > 3) then + local to_add = bck_iterator:prev(); + if to_add then remove_last() - end - if (first_index > 0 and this_item - first_index < 5) then - local to_add = bck_iterator:prev(); - if to_add then - add_item(to_add, first_index-1) - end - end + add_item(to_add, first_index-1) + refresh_group() + end + end end last_selected = this_item - refresh_group() end) btn:add_style(styles.list_item) return btn |
