From 819b2d33b04b2180b6ef19dab7f86af7d3603a52 Mon Sep 17 00:00:00 2001 From: Lysec Date: Sat, 4 Apr 2026 15:35:21 +0200 Subject: [PATCH] perf(ui): step NScrollText marquee on a timer instead of infinite animation Issue: #2393 --- Widgets/NScrollText.qml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Widgets/NScrollText.qml b/Widgets/NScrollText.qml index 0360ea743..32859dc77 100644 --- a/Widgets/NScrollText.qml +++ b/Widgets/NScrollText.qml @@ -40,6 +40,9 @@ Item { property real scrollCycleDuration: Math.max(4000, root.text.length * 120) property real resettingDuration: 300 + // Stepped marquee: avoids NumberAnimation.Infinite (~every vsync). ~17ms ≈ 60 updates/s. + property int scrollTickIntervalMs: 16 + // Fade controls (fadeExtent: 0.0–0.5, fraction of width that fades) property real fadeExtent: 0.1 property real fadeCornerRadius: 0 @@ -101,6 +104,22 @@ Item { } } + Timer { + id: marqueeTimer + interval: root.scrollTickIntervalMs + repeat: true + running: root.state === NScrollText.ScrollState.Scrolling + onTriggered: { + const cw = titleText.width + scrollContainer.spacing; + if (cw <= 0 || root.scrollCycleDuration <= 0) + return; + const step = cw * (marqueeTimer.interval / root.scrollCycleDuration); + scrollContainer.x -= step; + if (scrollContainer.x <= -cw) + scrollContainer.x += cw; + } + } + MouseArea { id: hoverArea anchors.fill: parent @@ -173,14 +192,6 @@ Item { root.updateState(); } } - - NumberAnimation on x { - running: root.state === NScrollText.ScrollState.Scrolling - to: -(titleText.width + scrollContainer.spacing) - duration: root.scrollCycleDuration - loops: Animation.Infinite - easing.type: Easing.Linear - } } // Transparency Fade Rectangle