From c5a42d8d2a127221fce43c20bc8406a8bbfcb9a6 Mon Sep 17 00:00:00 2001 From: DuvelCorp Date: Thu, 10 Sep 2026 17:42:07 +0200 Subject: [PATCH] zBar: cap stagger window + shorter slide so a full bar assembles quickly --- modules/zhunter/zBar.lua | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/zhunter/zBar.lua b/modules/zhunter/zBar.lua index 1475807..580078f 100644 --- a/modules/zhunter/zBar.lua +++ b/modules/zhunter/zBar.lua @@ -292,18 +292,35 @@ 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 - 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.32, "outBack", { delay = (i - 1) * 0.06 }) + table.insert(shownButtons, btn) 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.05 + if count > 1 then + local maxWindow = 0.28 + 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.26, "outBack", { delay = (i - 1) * step }) + end end -- Called when the user toggles the Enable checkbox in the options.