Make `Scrollbar` follow `force_status` when animations are disabled

This commit is contained in:
Guldoman 2022-11-15 21:08:33 +01:00
parent 519b91c2dd
commit 51f2a291d3
No known key found for this signature in database
GPG Key ID: EA928C8BDA1A8825
1 changed files with 18 additions and 18 deletions

View File

@ -288,26 +288,26 @@ end
---Updates the scrollbar animations ---Updates the scrollbar animations
function Scrollbar:update() function Scrollbar:update()
-- TODO: move the animation code to its own class -- TODO: move the animation code to its own class
local dest = (self.hovering.track or self.dragging) and 1 or 0 if not self.force_status then
local diff = math.abs(self.expand_percent - dest) local dest = (self.hovering.track or self.dragging) and 1 or 0
if not config.transitions or diff < 0.05 or config.disabled_transitions["scroll"] then local diff = math.abs(self.expand_percent - dest)
self.expand_percent = dest if not config.transitions or diff < 0.05 or config.disabled_transitions["scroll"] then
else self.expand_percent = dest
local rate = 0.3 else
if config.fps ~= 60 or config.animation_rate ~= 1 then local rate = 0.3
local dt = 60 / config.fps if config.fps ~= 60 or config.animation_rate ~= 1 then
rate = 1 - common.clamp(1 - rate, 1e-8, 1 - 1e-8)^(config.animation_rate * dt) local dt = 60 / config.fps
end rate = 1 - common.clamp(1 - rate, 1e-8, 1 - 1e-8)^(config.animation_rate * dt)
if not self.force_status then end
self.expand_percent = common.lerp(self.expand_percent, dest, rate) self.expand_percent = common.lerp(self.expand_percent, dest, rate)
elseif self.force_status == "expanded" then
self.expand_percent = 1
elseif self.force_status == "contracted" then
self.expand_percent = 0
end end
end if diff > 1e-8 then
if diff > 1e-8 then core.redraw = true
core.redraw = true end
elseif self.force_status == "expanded" then
self.expand_percent = 1
elseif self.force_status == "contracted" then
self.expand_percent = 0
end end
end end