fix: always scroll to last item and only scroll when at bottom

Fixes #77
This commit is contained in:
Jonathan Rainville 2020-05-20 15:10:09 -04:00 committed by Iuri Matias
parent 98ce32204d
commit e157b1bc6d
1 changed files with 13 additions and 52 deletions

View File

@ -332,62 +332,23 @@ SplitView {
Layout.fillWidth: true
Layout.fillHeight: true
delegate: chatLogViewDelegate
highlightFollowsCurrentItem: true
onCountChanged: {
chatLogView.positionViewAtEnd()
if (!this.atYEnd) {
// User has scrolled up, we don't want to scroll back
return;
}
// positionViewAtEnd doesn't work well. Instead, we use highlightFollowsCurrentItem
// and set the current Item/Index to the latest item
while (this.currentIndex < this.count - 1) {
this.incrementCurrentIndex()
}
}
}
}
// RowLayout {
// id: separator
// height: 16
// Layout.fillWidth: true
// Layout.alignment: Qt.AlignLeft | Qt.AlignTop
// Item {
// id: separatorContent
// width: 200
// height: 16
// Layout.fillHeight: false
// Layout.fillWidth: true
// Rectangle {
// id: lineSeparator1
// height: 1
// color: "#00000000"
// border.color: "#eef2f5"
// anchors.top: parent.top
// anchors.topMargin: 8
// anchors.right: separatorText.left
// anchors.rightMargin: 14
// anchors.left: parent.left
// anchors.leftMargin: 16
// }
// Text {
// id: separatorText
// color: Theme.darkGrey
// text: qsTr("Yesterday")
// font.pixelSize: 12
// anchors.centerIn: parent
// }
// Rectangle {
// id: lineSeparator2
// height: 1
// color: "#00000000"
// anchors.right: parent.right
// anchors.rightMargin: 16
// anchors.left: separatorText.right
// border.color: "#eef2f5"
// anchors.top: parent.top
// anchors.leftMargin: 14
// anchors.topMargin: 8
// }
// }
// }
RowLayout {
id: chatInputContainer
height: 70
@ -474,6 +435,6 @@ SplitView {
}
/*##^##
Designer {
D{i:0;formeditorZoom:0.75;height:770;width:1152}
D{i:0;formeditorZoom:0.5;height:770;width:1152}
}
##^##*/