restore-chat: dynamic scroll to bottom
no more un-reliable timer, we now always for sure going to bottom!
This commit is contained in:
+24
-4
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user