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