From 7e27ef88fe08b806188fd1c6c952efffb3086a3d Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 26 Oct 2016 11:34:09 +0200 Subject: [PATCH] feat(Collapse): use transitions and states attributes --- tests/ui/modules/Common/Collapse.qml | 44 +++++++++++++++++++++------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/tests/ui/modules/Common/Collapse.qml b/tests/ui/modules/Common/Collapse.qml index 375411124..7bc5ba39a 100644 --- a/tests/ui/modules/Common/Collapse.qml +++ b/tests/ui/modules/Common/Collapse.qml @@ -11,16 +11,18 @@ Item { signal collapsed (bool collapsed) + // ----------------------------------------------------------------- + function collapse () { _collapsed = !_collapsed - collapsed(_collapsed) - rotate.start() } function isCollapsed () { return _collapsed } + // ----------------------------------------------------------------- + ActionButton { id: button @@ -32,14 +34,36 @@ Item { onClicked: collapse() } - RotationAnimation { - id: rotate + // ----------------------------------------------------------------- - direction: RotationAnimation.Clockwise - duration: CollapseStyle.animationDuration - from: _collapsed ? 0 : 180 - property: 'rotation' - target: button - to: _collapsed ? 180 : 0 + states: [ + State { + name: 'Collapsed' + when: _collapsed + + PropertyChanges { + target: button + rotation: 180 + } + } + ] + + transitions: Transition { + RotationAnimation { + direction: RotationAnimation.Clockwise + duration: CollapseStyle.animationDuration + property: 'rotation' + target: button + } + + SequentialAnimation { + PauseAnimation { + duration: CollapseStyle.animationDuration + } + + ScriptAction { + script: collapsed(_collapsed) + } + } } }