diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-05-14 16:34:37 +1000 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-05-14 16:34:37 +1000 |
| commit | e06a09619467dc5673b41ae05c7261101cf41bd1 (patch) | |
| tree | 5b1795aac8fd63129f36f9f48841f2a7ad0f2f51 /lua/widgets.lua | |
| parent | defe838ab01da8502de13d3c75e008624d1e675a (diff) | |
| download | tangara-fw-e06a09619467dc5673b41ae05c7261101cf41bd1.tar.gz | |
Minor improvements to infinite list widget
Diffstat (limited to 'lua/widgets.lua')
| -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 |
