diff options
| author | Carl Schwan <carl.schwan@kdab.com> | 2023-02-08 17:58:48 +0100 |
|---|---|---|
| committer | Carl Schwan <carl.schwan@kdab.com> | 2023-02-16 18:32:48 +0100 |
| commit | 921ec15f38aa658738d2c3557e50307fe7ddfc9d (patch) | |
| tree | 5033e6471f7d7d44b6f3371f99916c222b610b7e /src/quickcontrols/material/StackView.qml | |
| parent | bf9a08559e5ac6945e53d0bbde8345ce38343adf (diff) | |
Simplify definition of transition in Material StackView
Refactor duplicate code inside inline components. This makes the code
nicer to read and easier to understand.
Change-Id: Ic617e6f59307fa519e94b90fee4c26daeb3d212b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quickcontrols/material/StackView.qml')
| -rw-r--r-- | src/quickcontrols/material/StackView.qml | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/quickcontrols/material/StackView.qml b/src/quickcontrols/material/StackView.qml index 241b91f2d7..c3182442a2 100644 --- a/src/quickcontrols/material/StackView.qml +++ b/src/quickcontrols/material/StackView.qml @@ -8,39 +8,56 @@ import QtQuick.Controls.Material T.StackView { id: control + component LineAnimation: NumberAnimation { + duration: 200 + easing.type: Easing.OutCubic + } + + component FadeIn: LineAnimation { + property: "opacity" + from: 0.0 + to: 1.0 + } + + component FadeOut: LineAnimation { + property: "opacity" + from: 1.0 + to: 0.0 + } + popEnter: Transition { // slide_in_left - NumberAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * -control.width; to: 0; duration: 200; easing.type: Easing.OutCubic } - NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 200; easing.type: Easing.OutCubic } + LineAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * -control.width; to: 0 } + FadeIn {} } popExit: Transition { // slide_out_right - NumberAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * control.width; duration: 200; easing.type: Easing.OutCubic } - NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 200; easing.type: Easing.OutCubic } + LineAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * control.width } + FadeOut {} } pushEnter: Transition { // slide_in_right - NumberAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * control.width; to: 0; duration: 200; easing.type: Easing.OutCubic } - NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 200; easing.type: Easing.OutCubic } + LineAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * control.width; to: 0 } + FadeIn {} } pushExit: Transition { // slide_out_left - NumberAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * -control.width; duration: 200; easing.type: Easing.OutCubic } - NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 200; easing.type: Easing.OutCubic } + LineAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * -control.width } + FadeOut {} } replaceEnter: Transition { // slide_in_right - NumberAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * control.width; to: 0; duration: 200; easing.type: Easing.OutCubic } - NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 200; easing.type: Easing.OutCubic } + LineAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * control.width; to: 0 } + FadeIn {} } replaceExit: Transition { // slide_out_left - NumberAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * -control.width; duration: 200; easing.type: Easing.OutCubic } - NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 200; easing.type: Easing.OutCubic } + LineAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * -control.width } + FadeOut {} } } |
