From 6d6266f03cef37aa488735e6c3134c704f5444c6 Mon Sep 17 00:00:00 2001 From: Black Date: Wed, 12 Feb 2020 00:57:45 -0800 Subject: [PATCH] Fix jumping issues. --- imports/Spectral/Panel/RoomPanel.qml | 100 ++++++++++++++------------- 1 file changed, 53 insertions(+), 47 deletions(-) diff --git a/imports/Spectral/Panel/RoomPanel.qml b/imports/Spectral/Panel/RoomPanel.qml index 506efa5b9..28e90bafe 100644 --- a/imports/Spectral/Panel/RoomPanel.qml +++ b/imports/Spectral/Panel/RoomPanel.qml @@ -31,10 +31,24 @@ Kirigami.ScrollablePage { room: currentRoom } + SortFilterProxyModel { + id: sortedMessageEventModel + + sourceModel: messageEventModel + + filters: [ + ExpressionFilter { + expression: marks !== 0x10 && eventType !== "other" + } + ] + } + ListView { readonly property int largestVisibleIndex: count > 0 ? indexAt(contentX + (width / 2), contentY + height - 1) : -1 readonly property bool noNeedMoreContent: !currentRoom || currentRoom.eventsHistoryJob || currentRoom.allHistoryLoaded + readonly property bool isLoaded: page.width * page.height > 10 + id: messageListView spacing: Kirigami.Units.smallSpacing @@ -44,62 +58,45 @@ Kirigami.ScrollablePage { verticalLayoutDirection: ListView.BottomToTop highlightMoveDuration: 500 - model: SortFilterProxyModel { - id: sortedMessageEventModel - - sourceModel: messageEventModel - - filters: [ - ExpressionFilter { - expression: marks !== 0x10 && eventType !== "other" - } - ] - - onModelReset: { - if (currentRoom) { - if (currentRoom.timelineSize < 20) - currentRoom.getPreviousContent(50) - } - } - } + model: !isLoaded ? undefined : sortedMessageEventModel onContentYChanged: { if(!noNeedMoreContent && contentY - 5000 < originY) currentRoom.getPreviousContent(20); } - populate: Transition { - NumberAnimation { - property: "opacity"; from: 0; to: 1 - duration: 200 - } - } +// populate: Transition { +// NumberAnimation { +// property: "opacity"; from: 0; to: 1 +// duration: 200 +// } +// } - add: Transition { - NumberAnimation { - property: "opacity"; from: 0; to: 1 - duration: 200 - } - } +// add: Transition { +// NumberAnimation { +// property: "opacity"; from: 0; to: 1 +// duration: 200 +// } +// } - move: Transition { - NumberAnimation { - property: "y"; duration: 200 - } - NumberAnimation { - property: "opacity"; to: 1 - } - } +// move: Transition { +// NumberAnimation { +// property: "y"; duration: 200 +// } +// NumberAnimation { +// property: "opacity"; to: 1 +// } +// } - displaced: Transition { - NumberAnimation { - property: "y"; duration: 200 - easing.type: Easing.OutQuad - } - NumberAnimation { - property: "opacity"; to: 1 - } - } +// displaced: Transition { +// NumberAnimation { +// property: "y"; duration: 200 +// easing.type: Easing.OutQuad +// } +// NumberAnimation { +// property: "opacity"; to: 1 +// } +// } delegate: DelegateChooser { role: "eventType" @@ -218,6 +215,15 @@ Kirigami.ScrollablePage { delegate: Item {} } } + + Component.onCompleted: { + if (currentRoom) { + if (currentRoom.timelineSize < 20) + currentRoom.getPreviousContent(50) + } + + positionViewAtBeginning() + } } footer: RowLayout {