fix: don't play add/remove anim on old delegates
This commit is contained in:
parent
7a82ca4765
commit
e234990c52
3 changed files with 17 additions and 8 deletions
|
|
@ -80,8 +80,8 @@ LazyListView {
|
||||||
LazyListView.visibleHeight: modelData?.closed || previewHidden ? 0 : notifInner.implicitHeight
|
LazyListView.visibleHeight: modelData?.closed || previewHidden ? 0 : notifInner.implicitHeight
|
||||||
implicitHeight: notifInner.implicitHeight
|
implicitHeight: notifInner.implicitHeight
|
||||||
|
|
||||||
opacity: LazyListView.removing || modelData?.closed || previewHidden || LazyListView.adding ? 0 : 1
|
opacity: previewHidden || LazyListView.adding ? 0 : 1
|
||||||
scale: LazyListView.removing || previewHidden ? 0.7 : LazyListView.adding ? 0.7 : 1
|
scale: previewHidden || LazyListView.adding ? 0.7 : 1
|
||||||
|
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: notifInner.body?.hoveredLink ? Qt.PointingHandCursor : pressed ? Qt.ClosedHandCursor : undefined
|
cursorShape: notifInner.body?.hoveredLink ? Qt.PointingHandCursor : pressed ? Qt.ClosedHandCursor : undefined
|
||||||
|
|
|
||||||
|
|
@ -367,6 +367,12 @@ void LazyListView::updatePolish() {
|
||||||
relayout();
|
relayout();
|
||||||
syncDelegates();
|
syncDelegates();
|
||||||
|
|
||||||
|
// Clear isNew flags — the add animation only plays for items created
|
||||||
|
// during the same polish cycle as their model insertion, not for
|
||||||
|
// delegates created later when scrolling items into the viewport.
|
||||||
|
for (auto& record : m_layout)
|
||||||
|
record.isNew = false;
|
||||||
|
|
||||||
// Position delegates — QML Behavior on y handles the animation
|
// Position delegates — QML Behavior on y handles the animation
|
||||||
for (auto& entry : m_delegates) {
|
for (auto& entry : m_delegates) {
|
||||||
if (!entry.item || entry.pendingRemoval || entry.pendingInsert)
|
if (!entry.item || entry.pendingRemoval || entry.pendingInsert)
|
||||||
|
|
@ -652,12 +658,14 @@ LazyListView::DelegateEntry LazyListView::createDelegate(int modelIndex) {
|
||||||
entry.item->setParentItem(this);
|
entry.item->setParentItem(this);
|
||||||
entry.item->setWidth(width());
|
entry.item->setWidth(width());
|
||||||
|
|
||||||
// Set adding = true before completeCreate so bindings see it during initial evaluation.
|
// Only set adding = true for genuinely new model items (not viewport entries).
|
||||||
// Cleared on the next frame in updatePolish when the item becomes visible.
|
// Cleared on the next frame in updatePolish when the item becomes visible.
|
||||||
|
if (modelIndex < static_cast<int>(m_layout.size()) && m_layout[modelIndex].isNew) {
|
||||||
auto* addingAttached =
|
auto* addingAttached =
|
||||||
qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(entry.item, true));
|
qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(entry.item, true));
|
||||||
if (addingAttached)
|
if (addingAttached)
|
||||||
addingAttached->setAdding(true);
|
addingAttached->setAdding(true);
|
||||||
|
}
|
||||||
|
|
||||||
m_delegate->completeCreate();
|
m_delegate->completeCreate();
|
||||||
|
|
||||||
|
|
@ -852,7 +860,7 @@ void LazyListView::onRowsInserted(const QModelIndex& parent, int first, int last
|
||||||
|
|
||||||
const int insertCount = last - first + 1;
|
const int insertCount = last - first + 1;
|
||||||
// Insert new layout records
|
// Insert new layout records
|
||||||
m_layout.insert(first, insertCount, ItemRecord{ 0, 0, false });
|
m_layout.insert(first, insertCount, ItemRecord{ 0, 0, false, true });
|
||||||
|
|
||||||
// Shift existing delegate indices
|
// Shift existing delegate indices
|
||||||
QHash<int, DelegateEntry> shifted;
|
QHash<int, DelegateEntry> shifted;
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,7 @@ private:
|
||||||
qreal targetY = 0;
|
qreal targetY = 0;
|
||||||
qreal height = 0;
|
qreal height = 0;
|
||||||
bool heightKnown = false;
|
bool heightKnown = false;
|
||||||
|
bool isNew = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DelegateEntry {
|
struct DelegateEntry {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue