diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-08-14 16:17:42 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-08-14 16:17:42 +0800 |
| commit | 7124a84274f4f7f11660983ce87e23d309da8adf (patch) | |
| tree | 7a3432ae3b70afd615a139c480535f0ae62c5c98 | |
| parent | e20c465cd276c2c80c253f1b4c201c8e56f1e980 (diff) | |
perf: IText
- 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
| -rw-r--r-- | components/IText.qml | 28 |
1 files changed, 11 insertions, 17 deletions
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(); + } + } } |
