Commit 7e27ef88 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Collapse): use transitions and states attributes

parent 5b209a04
...@@ -11,16 +11,18 @@ Item { ...@@ -11,16 +11,18 @@ Item {
signal collapsed (bool collapsed) signal collapsed (bool collapsed)
// -----------------------------------------------------------------
function collapse () { function collapse () {
_collapsed = !_collapsed _collapsed = !_collapsed
collapsed(_collapsed)
rotate.start()
} }
function isCollapsed () { function isCollapsed () {
return _collapsed return _collapsed
} }
// -----------------------------------------------------------------
ActionButton { ActionButton {
id: button id: button
...@@ -32,14 +34,36 @@ Item { ...@@ -32,14 +34,36 @@ Item {
onClicked: collapse() onClicked: collapse()
} }
RotationAnimation { // -----------------------------------------------------------------
id: rotate
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
}
direction: RotationAnimation.Clockwise ScriptAction {
duration: CollapseStyle.animationDuration script: collapsed(_collapsed)
from: _collapsed ? 0 : 180 }
property: 'rotation' }
target: button
to: _collapsed ? 180 : 0
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment