mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
perf(ui): step NScrollText marquee on a timer instead of infinite animation
Issue: #2393
This commit is contained in:
+19
-8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user