From ec2a41e390780cfdc01ab6d15a2ff64d4ef0d87a Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Mon, 25 Aug 2025 13:54:10 +0200 Subject: [PATCH] Animation ScrollText fix --- src/plugins/animation.lua | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/plugins/animation.lua b/src/plugins/animation.lua index c4b8793..105075b 100644 --- a/src/plugins/animation.lua +++ b/src/plugins/animation.lua @@ -439,15 +439,34 @@ Animation.registerAnimation("fadeText", { Animation.registerAnimation("scrollText", { start = function(anim) anim.width = anim.element.get("width") - anim.targetText = anim.args[2] - anim.element.set(anim.args[1], "") + anim.startText = anim.element.get(anim.args[1]) or "" + anim.targetText = anim.args[2] or "" + anim.startText = tostring(anim.startText) + anim.targetText = tostring(anim.targetText) end, update = function(anim, progress) - local offset = math.floor(anim.width * (1-progress)) - local spaces = string.rep(" ", offset) - anim.element.set(anim.args[1], spaces .. anim.targetText) + local w = anim.width + + if progress < 0.5 then + local p = progress / 0.5 + local offset = math.floor(w * p) + local visible = (anim.startText:sub(offset + 1) .. string.rep(" ", w)):sub(1, w) + anim.element.set(anim.args[1], visible) + else + local p = (progress - 0.5) / 0.5 + local leftSpaces = math.floor(w * (1 - p)) + local incoming = string.rep(" ", leftSpaces) .. anim.targetText + local visible = incoming:sub(1, w) + anim.element.set(anim.args[1], visible) + end + return progress >= 1 + end, + + complete = function(anim) + local final = (anim.targetText .. string.rep(" ", anim.width)) + anim.element.set(anim.args[1], final) end })