From 25a0943087ddd9b70e6bb6b7b6bbfcf5088a6ca5 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sat, 26 Aug 2023 05:11:10 +0200 Subject: [PATCH] Add `NaN` guard to `View:update_scrollbar` --- data/core/view.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/data/core/view.lua b/data/core/view.lua index b204afdc..bab75b01 100644 --- a/data/core/view.lua +++ b/data/core/view.lua @@ -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