From 7124a84274f4f7f11660983ce87e23d309da8adf Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 14 Aug 2025 16:17:42 +0800 Subject: perf: IText MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - No Behavior on text → avoids QML’s implicit animation overhead - No SequentialAnimation → less object creation - Reuses a single NumberAnimation instance - Manual triggering means nothing happens unless you explicitly want it --- components/IText.qml | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'components') diff --git a/components/IText.qml b/components/IText.qml index c528dc2..413da2c 100644 --- a/components/IText.qml +++ b/components/IText.qml @@ -30,26 +30,20 @@ Text { } } - Behavior on text { - enabled: root.animate - - SequentialAnimation { - Anim { - to: root.animateFrom - easing.bezierCurve: Style.anim.curves.standardAccel - } - PropertyAction {} - Anim { - to: root.animateTo - easing.bezierCurve: Style.anim.curves.standardDecel - } - } - } - - component Anim: NumberAnimation { + NumberAnimation { + id: scaleAnim target: root property: "scale" duration: General.animationDuration / 4 easing.type: Easing.BezierSpline } + + onTextChanged: { + if (animate) { + root.scale = animateFrom; + scaleAnim.to = animateTo; + scaleAnim.easing.bezierCurve = Style.anim.curves.standardAccel; + scaleAnim.start(); + } + } } -- cgit v1.2.3