fix: don't add delegate to layout until ready delay finish

Also disable y anim if not ready
This commit is contained in:
2 * r + 2 * t 2026-04-10 01:38:12 +10:00
parent e234990c52
commit c629eaaa08
4 changed files with 43 additions and 9 deletions

View file

@ -120,6 +120,8 @@ LazyListView {
}
Behavior on y {
enabled: notif.LazyListView.ready
Anim {
duration: Appearance.anim.durations.expressiveDefaultSpatial
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial

View file

@ -140,6 +140,8 @@ LazyListView {
}
Behavior on y {
enabled: notif.LazyListView.ready
Anim {
duration: Appearance.anim.durations.expressiveDefaultSpatial
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial

View file

@ -344,23 +344,52 @@ void LazyListView::updatePolish() {
if (!m_componentComplete || !m_model || !m_delegate)
return;
// Flush pending inserts from the previous frame — make items visible
// and clear the adding flag so enter animations begin.
// Flush pending inserts — make items visible and clear the adding flag
// so enter animations begin. When readyDelay > 0 the entire insert is
// deferred so delegates have time to lay out before appearing.
for (auto& entry : m_delegates) {
if (!entry.pendingInsert || !entry.item)
continue;
if (m_readyDelay > 0) {
if (!entry.readyDelayStarted) {
entry.readyDelayStarted = true;
auto* item = entry.item;
QTimer::singleShot(m_readyDelay, this, [this, item] {
auto indexIt = m_itemToIndex.find(item);
if (indexIt == m_itemToIndex.end())
return;
const int idx = indexIt.value();
auto it = m_delegates.find(idx);
if (it == m_delegates.end() || it->item != item || !it->pendingInsert)
return;
it->pendingInsert = false;
it->readyDelayStarted = false;
// Position correctly before making visible
if (idx >= 0 && idx < static_cast<int>(m_layout.size()))
item->setY(m_layout[idx].targetY - m_contentY);
item->setVisible(true);
auto* att =
qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(item, false));
if (att) {
att->setAdding(false);
att->setReady(true);
}
polish();
});
}
continue;
}
entry.pendingInsert = false;
entry.item->setVisible(true);
auto* att = qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(entry.item, false));
if (att) {
att->setAdding(false);
if (m_readyDelay > 0) {
QTimer::singleShot(m_readyDelay, att, [att] {
att->setReady(true);
});
} else {
att->setReady(true);
}
att->setReady(true);
}
}

View file

@ -177,6 +177,7 @@ private:
QQuickItem* item = nullptr;
bool pendingRemoval = false;
bool pendingInsert = false;
bool readyDelayStarted = false;
};
// Layout