zBar: revert to plain staggered fade + no init animation (SlideIn caused client micro-freezes on reload)

This commit is contained in:
DuvelCorp
2026-09-10 17:48:46 +02:00
parent 2863adff1c
commit 64e449481f
+6 -22
View File
@@ -285,6 +285,10 @@ function MTH_ZBar_Release()
end
-- Animations: gentle staggered fade-in of the bar's buttons when it activates.
-- NOTE: keep this a plain alpha fade only. A SlideIn (position tween) here caused
-- client micro-freezes on reload because it re-anchors every chained button each
-- frame, forcing repeated layout recalcs. Use position/scale tweens on the zBar
-- with extreme caution.
function MTH_ZBar_AnimateActivate()
if not ZBar_Sauce then return end
if type(MTH_FX_IsEnabled) ~= "function" or not MTH_FX_IsEnabled("ui.zbar") then
@@ -292,35 +296,16 @@ function MTH_ZBar_AnimateActivate()
end
local s = MTH_ZBar_GetSaved()
local order = s.order or {}
-- Collect only the buttons that will actually animate so the stagger is based
-- on the visible count, not gaps in the saved order.
local shownButtons = {}
for i = 1, table.getn(order) do
local buttonName = order[i]
if type(buttonName) == "string" then
local btn = getglobal(buttonName)
if btn and btn:IsShown() then
table.insert(shownButtons, btn)
btn:SetAlpha(0)
ZBar_Sauce:FadeTo(btn, 1, 0.30, "outQuad", { delay = (i - 1) * 0.05 })
end
end
end
local count = table.getn(shownButtons)
-- Cap the total stagger window so a full bar assembles just as quickly as a
-- short one: the per-button delay shrinks as the button count grows.
local step = 0.02
if count > 1 then
local maxWindow = 0.10
if step * (count - 1) > maxWindow then
step = maxWindow / (count - 1)
end
end
for i = 1, count do
local btn = shownButtons[i]
btn:SetAlpha(0)
-- Staggered springy slide-up so the bar visibly assembles button by
-- button instead of a faint collective fade.
ZBar_Sauce:SlideIn(btn, "UP", 26, 0.14, "outBack", { delay = (i - 1) * step })
end
end
-- Called when the user toggles the Enable checkbox in the options.
@@ -371,6 +356,5 @@ function MTH_ZBar_Init()
if s.enabled then
MTH_ZBar_EnsureAnchor()
MTH_ZBar_ApplyLayout()
MTH_ZBar_AnimateActivate()
end
end