Make `Scrollbar` follow `force_status` when animations are disabled
This commit is contained in:
parent
519b91c2dd
commit
51f2a291d3
|
@ -288,26 +288,26 @@ end
|
|||
---Updates the scrollbar animations
|
||||
function Scrollbar:update()
|
||||
-- TODO: move the animation code to its own class
|
||||
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
|
||||
self.expand_percent = dest
|
||||
else
|
||||
local rate = 0.3
|
||||
if config.fps ~= 60 or config.animation_rate ~= 1 then
|
||||
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
|
||||
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
|
||||
self.expand_percent = dest
|
||||
else
|
||||
local rate = 0.3
|
||||
if config.fps ~= 60 or config.animation_rate ~= 1 then
|
||||
local dt = 60 / config.fps
|
||||
rate = 1 - common.clamp(1 - rate, 1e-8, 1 - 1e-8)^(config.animation_rate * dt)
|
||||
end
|
||||
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
|
||||
if diff > 1e-8 then
|
||||
core.redraw = true
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue