Animate SidePane width only when collapsing

To avoid RoomHeaderButton collapse bug due to the "slowly" changing
Chat width.
This commit is contained in:
miruka 2019-05-12 16:13:00 -04:00
parent 46d5704eb6
commit b9b6d2fcb3
4 changed files with 18 additions and 12 deletions

View File

@ -78,7 +78,7 @@ HRectangle {
}
Behavior on Layout.maximumWidth {
NumberAnimation { id: buttonsAnimation; duration: 150 }
NumberAnimation { id: buttonsAnimation; duration: 120 }
}
}
}

View File

@ -21,7 +21,7 @@ Column {
bottomMargin: topMargin
Behavior on spacing {
NumberAnimation { duration: 150 }
NumberAnimation { duration: 120 }
}
model: chatPage.roomInfo.members

View File

@ -21,17 +21,10 @@ HRectangle {
Layout.leftMargin: spacing
Behavior on spacing {
NumberAnimation { duration: 150 }
NumberAnimation { duration: 120 }
}
}
PaneToolBar {}
}
Behavior on width {
NumberAnimation {
// Don't slow down the user manually resizing
duration: uiSplitView.canAutoSize ? 150 : 0
}
}
}

View File

@ -24,20 +24,33 @@ Item {
anchors.fill: parent
SidePane {
id: sidePane
visible: accountsLoggedIn
collapsed: width < Layout.minimumWidth + normalSpacing
property int parentWidth: parent.width
property int collapseBelow: 120
function set_width() {
width = parent.width * 0.3 < 120 ?
width = parent.width * 0.3 < collapseBelow ?
Layout.minimumWidth : Math.min(parent.width * 0.3, 300)
}
property int parentWidth: parent.width
onParentWidthChanged: if (uiSplitView.canAutoSize) { set_width() }
width: set_width() // Initial width
Layout.minimumWidth: HStyle.avatar.size
Layout.maximumWidth: parent.width
Behavior on width {
NumberAnimation {
// Don't slow down the user manually resizing
duration:
(uiSplitView.canAutoSize &&
parent.width * 0.3 < sidePane.collapseBelow * 1.2) ?
120 : 0
}
}
}
StackView {