From e234990c52f20d31c3b038dbc1d69c94b813ba95 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Fri, 10 Apr 2026 01:25:09 +1000 Subject: [PATCH] fix: don't play add/remove anim on old delegates --- modules/sidebar/NotifGroupList.qml | 4 ++-- .../src/Caelestia/Components/lazylistview.cpp | 20 +++++++++++++------ .../src/Caelestia/Components/lazylistview.hpp | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/modules/sidebar/NotifGroupList.qml b/modules/sidebar/NotifGroupList.qml index 112db493..49330612 100644 --- a/modules/sidebar/NotifGroupList.qml +++ b/modules/sidebar/NotifGroupList.qml @@ -80,8 +80,8 @@ LazyListView { LazyListView.visibleHeight: modelData?.closed || previewHidden ? 0 : notifInner.implicitHeight implicitHeight: notifInner.implicitHeight - opacity: LazyListView.removing || modelData?.closed || previewHidden || LazyListView.adding ? 0 : 1 - scale: LazyListView.removing || previewHidden ? 0.7 : LazyListView.adding ? 0.7 : 1 + opacity: previewHidden || LazyListView.adding ? 0 : 1 + scale: previewHidden || LazyListView.adding ? 0.7 : 1 hoverEnabled: true cursorShape: notifInner.body?.hoveredLink ? Qt.PointingHandCursor : pressed ? Qt.ClosedHandCursor : undefined diff --git a/plugin/src/Caelestia/Components/lazylistview.cpp b/plugin/src/Caelestia/Components/lazylistview.cpp index 14545578..653fe97b 100644 --- a/plugin/src/Caelestia/Components/lazylistview.cpp +++ b/plugin/src/Caelestia/Components/lazylistview.cpp @@ -367,6 +367,12 @@ void LazyListView::updatePolish() { relayout(); 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 for (auto& entry : m_delegates) { if (!entry.item || entry.pendingRemoval || entry.pendingInsert) @@ -652,12 +658,14 @@ LazyListView::DelegateEntry LazyListView::createDelegate(int modelIndex) { entry.item->setParentItem(this); 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. - auto* addingAttached = - qobject_cast(qmlAttachedPropertiesObject(entry.item, true)); - if (addingAttached) - addingAttached->setAdding(true); + if (modelIndex < static_cast(m_layout.size()) && m_layout[modelIndex].isNew) { + auto* addingAttached = + qobject_cast(qmlAttachedPropertiesObject(entry.item, true)); + if (addingAttached) + addingAttached->setAdding(true); + } m_delegate->completeCreate(); @@ -852,7 +860,7 @@ void LazyListView::onRowsInserted(const QModelIndex& parent, int first, int last const int insertCount = last - first + 1; // 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 QHash shifted; diff --git a/plugin/src/Caelestia/Components/lazylistview.hpp b/plugin/src/Caelestia/Components/lazylistview.hpp index feb501c6..a027d19a 100644 --- a/plugin/src/Caelestia/Components/lazylistview.hpp +++ b/plugin/src/Caelestia/Components/lazylistview.hpp @@ -169,6 +169,7 @@ private: qreal targetY = 0; qreal height = 0; bool heightKnown = false; + bool isNew = false; }; struct DelegateEntry {