moment/src/gui/Base/DelegateTransitionFixer.qml
miruka 8acc7299e9 Add workaround for delegate stuck transition bug
Sometimes and randomly, a HListView/HGridView delegate's
add/populate transition will stop before completion.

This especially happens on startup when loading a large room list,
one room might get stuck and left tiny or invisible, despite its
normal space still being taken.
2021-03-03 17:12:08 -04:00

36 lines
1022 B
QML

// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
Timer {
// Sometimes and randomly, a HListView/HGridView delegate's add/populate
// Transition will stop too early, leaving a stuck invisible or tiny item.
// This is a workaround for this Qt bug happening despite the neccessary
// Transition precautions from the docs being applied.
property Item delegate: parent
readonly property HNumberAnimation opacityFixer: HNumberAnimation {
target: delegate
property: "opacity"
from: delegate.opacity
to: 1
}
readonly property HNumberAnimation scaleFixer: HNumberAnimation {
target: delegate
property: "scale"
from: delegate.scale
to: 1
}
interval: theme.animationDuration * 2
running: true
onTriggered: {
// if (delegate.opacity < 1 || delegate.scale < 1) print(delegate)
if (delegate.opacity < 1) opacityFixer.start()
if (delegate.scale < 1) scaleFixer.start()
}
}