Update widgets.lua

develop
Myk 2023-05-19 12:12:52 -07:00 committed by GitHub
parent bd7ac0453b
commit 57d2edc84e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

@ -1664,9 +1664,9 @@ function List:setChoices(choices, selected)
-- Check if page_top needs to be adjusted -- Check if page_top needs to be adjusted
if #self.choices - self.page_size < 0 then if #self.choices - self.page_size < 0 then
self.page_top = 1 self.page_top = 1
elseif self.selected <= math.floor(self.page_size / 2) then elseif self.selected <= (self.page_size // 2) then
self.page_top = 1 self.page_top = 1
elseif self.selected >= #self.choices - math.floor(self.page_size / 2) then elseif self.selected >= #self.choices - (self.page_size // 2) then
self.page_top = #self.choices - self.page_size + 1 self.page_top = #self.choices - self.page_size + 1
end end
end end
@ -1709,7 +1709,7 @@ local function update_list_scrollbar(list)
end end
function List:postComputeFrame(body) function List:postComputeFrame(body)
local row_count = math.floor(body.height / self.row_height) local row_count = body.height // self.row_height
self.page_size = math.max(1, row_count) self.page_size = math.max(1, row_count)
local num_choices = #self.choices local num_choices = #self.choices