restore-chat: dynamic scroll to bottom

no more un-reliable timer, we now always for sure going to bottom!
This commit is contained in:
Sattva
2025-05-16 06:52:53 +03:00
parent f1dee170ac
commit de6aedc9dc
+24 -4
View File
@@ -13340,10 +13340,30 @@ function LeaPlusLC:Player()
title.count:SetText("Messages: "..count) title.count:SetText("Messages: "..count)
ResizeEdit(count) ResizeEdit(count)
LibCompat.After(0.1, function()
-- scroll to bottom local function ScrollToBottomReliable(scroll, edit, maxAttempts)
scroll:SetVerticalScroll(scroll:GetVerticalScrollRange()) maxAttempts = maxAttempts or 20
end) local lastHeight = 0
local attempts = 0
local function tryScroll()
attempts = attempts + 1
local curHeight = edit:GetHeight()
if curHeight ~= lastHeight and attempts < maxAttempts then
lastHeight = curHeight
LibCompat.After(0.02, tryScroll)
else
scroll:SetVerticalScroll(scroll:GetVerticalScrollRange())
end
end
tryScroll()
end
ScrollToBottomReliable(scroll, edit)
frame:Show() frame:Show()
end end