perf(ui): step NScrollText marquee on a timer instead of infinite animation

Issue: #2393
This commit is contained in:
Lysec
2026-04-04 15:35:21 +02:00
parent a0093e509b
commit 819b2d33b0
+19 -8
View File
@@ -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.00.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