Add `NaN` guard to `View:update_scrollbar`
This commit is contained in:
parent
cb66d5b9e7
commit
3f28557aeb
|
@ -287,12 +287,16 @@ end
|
|||
function View:update_scrollbar()
|
||||
local v_scrollable = self:get_scrollable_size()
|
||||
self.v_scrollbar:set_size(self.position.x, self.position.y, self.size.x, self.size.y, v_scrollable)
|
||||
self.v_scrollbar:set_percent(self.scroll.y/(v_scrollable - self.size.y))
|
||||
local v_percent = self.scroll.y/(v_scrollable - self.size.y)
|
||||
-- Avoid setting nan percent
|
||||
self.v_scrollbar:set_percent(v_percent == v_percent and v_percent or 0)
|
||||
self.v_scrollbar:update()
|
||||
|
||||
local h_scrollable = self:get_h_scrollable_size()
|
||||
self.h_scrollbar:set_size(self.position.x, self.position.y, self.size.x, self.size.y, h_scrollable)
|
||||
self.h_scrollbar:set_percent(self.scroll.x/(h_scrollable - self.size.x))
|
||||
local h_percent = self.scroll.x/(h_scrollable - self.size.x)
|
||||
-- Avoid setting nan percent
|
||||
self.h_scrollbar:set_percent(h_percent == h_percent and h_percent or 0)
|
||||
self.h_scrollbar:update()
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue