Disable link loading animation when offscreen
Stop the link preview loading indicator animation running when the delegate isn't visible. CCBUG: 465715
This commit is contained in:
@@ -44,6 +44,11 @@ Loader {
|
|||||||
*/
|
*/
|
||||||
property var defaultHeight : Kirigami.Units.gridUnit * 3 + Kirigami.Units.smallSpacing * 2
|
property var defaultHeight : Kirigami.Units.gridUnit * 3 + Kirigami.Units.smallSpacing * 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether the loading indicator should animate if visible.
|
||||||
|
*/
|
||||||
|
property bool indicatorEnabled: false
|
||||||
|
|
||||||
active: !currentRoom.usesEncryption && model.display && links && links.length > 0
|
active: !currentRoom.usesEncryption && model.display && links && links.length > 0
|
||||||
visible: Config.showLinkPreview && active
|
visible: Config.showLinkPreview && active
|
||||||
sourceComponent: linkPreviewer.loaded ? linkPreviewComponent : loadingComponent
|
sourceComponent: linkPreviewer.loaded ? linkPreviewComponent : loadingComponent
|
||||||
@@ -129,7 +134,7 @@ Loader {
|
|||||||
Component {
|
Component {
|
||||||
id: loadingComponent
|
id: loadingComponent
|
||||||
RowLayout {
|
RowLayout {
|
||||||
property bool hovered: false
|
id: componentRoot
|
||||||
property bool truncated: false
|
property bool truncated: false
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -137,7 +142,9 @@ Loader {
|
|||||||
width: Kirigami.Units.smallSpacing
|
width: Kirigami.Units.smallSpacing
|
||||||
color: Kirigami.Theme.highlightColor
|
color: Kirigami.Theme.highlightColor
|
||||||
}
|
}
|
||||||
QQC2.BusyIndicator { }
|
QQC2.BusyIndicator {
|
||||||
|
running: root.indicatorEnabled
|
||||||
|
}
|
||||||
Kirigami.Heading {
|
Kirigami.Heading {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.minimumHeight: root.defaultHeight
|
Layout.minimumHeight: root.defaultHeight
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ TimelineContainer {
|
|||||||
}
|
}
|
||||||
LinkPreviewDelegate {
|
LinkPreviewDelegate {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
indicatorEnabled: messageDelegate.isVisibleInTimeline()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -320,4 +320,9 @@ ColumnLayout {
|
|||||||
|
|
||||||
visible: eventType !== MessageEventModel.State && eventType !== MessageEventModel.Notice && reaction != undefined && reaction.length > 0
|
visible: eventType !== MessageEventModel.State && eventType !== MessageEventModel.Notice && reaction != undefined && reaction.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isVisibleInTimeline() {
|
||||||
|
let yoff = Math.round(y - ListView.view.contentY);
|
||||||
|
return (yoff + height > 0 && yoff < ListView.view.height)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user