From de6aedc9dc4d53f4f9347d9f34ae7b6309e9ed19 Mon Sep 17 00:00:00 2001 From: Sattva <74269253+Sattva-108@users.noreply.github.com> Date: Fri, 16 May 2025 06:52:53 +0300 Subject: [PATCH] restore-chat: dynamic scroll to bottom no more un-reliable timer, we now always for sure going to bottom! --- Leatrix_Plus.lua | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Leatrix_Plus.lua b/Leatrix_Plus.lua index e985c2d..6421430 100644 --- a/Leatrix_Plus.lua +++ b/Leatrix_Plus.lua @@ -13340,10 +13340,30 @@ function LeaPlusLC:Player() title.count:SetText("Messages: "..count) ResizeEdit(count) - LibCompat.After(0.1, function() - -- scroll to bottom - scroll:SetVerticalScroll(scroll:GetVerticalScrollRange()) - end) + + local function ScrollToBottomReliable(scroll, edit, maxAttempts) + maxAttempts = maxAttempts or 20 + 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() end