fix: don't add delegate to layout until ready delay finish
Also disable y anim if not ready
This commit is contained in:
parent
e234990c52
commit
c629eaaa08
4 changed files with 43 additions and 9 deletions
|
|
@ -120,6 +120,8 @@ LazyListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on y {
|
Behavior on y {
|
||||||
|
enabled: notif.LazyListView.ready
|
||||||
|
|
||||||
Anim {
|
Anim {
|
||||||
duration: Appearance.anim.durations.expressiveDefaultSpatial
|
duration: Appearance.anim.durations.expressiveDefaultSpatial
|
||||||
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
|
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,8 @@ LazyListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on y {
|
Behavior on y {
|
||||||
|
enabled: notif.LazyListView.ready
|
||||||
|
|
||||||
Anim {
|
Anim {
|
||||||
duration: Appearance.anim.durations.expressiveDefaultSpatial
|
duration: Appearance.anim.durations.expressiveDefaultSpatial
|
||||||
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
|
easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
|
||||||
|
|
|
||||||
|
|
@ -344,23 +344,52 @@ void LazyListView::updatePolish() {
|
||||||
if (!m_componentComplete || !m_model || !m_delegate)
|
if (!m_componentComplete || !m_model || !m_delegate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Flush pending inserts from the previous frame — make items visible
|
// Flush pending inserts — make items visible and clear the adding flag
|
||||||
// and clear the adding flag so enter animations begin.
|
// 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) {
|
for (auto& entry : m_delegates) {
|
||||||
if (!entry.pendingInsert || !entry.item)
|
if (!entry.pendingInsert || !entry.item)
|
||||||
continue;
|
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.pendingInsert = false;
|
||||||
entry.item->setVisible(true);
|
entry.item->setVisible(true);
|
||||||
auto* att = qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(entry.item, false));
|
auto* att = qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(entry.item, false));
|
||||||
if (att) {
|
if (att) {
|
||||||
att->setAdding(false);
|
att->setAdding(false);
|
||||||
if (m_readyDelay > 0) {
|
|
||||||
QTimer::singleShot(m_readyDelay, att, [att] {
|
|
||||||
att->setReady(true);
|
att->setReady(true);
|
||||||
});
|
|
||||||
} else {
|
|
||||||
att->setReady(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ private:
|
||||||
QQuickItem* item = nullptr;
|
QQuickItem* item = nullptr;
|
||||||
bool pendingRemoval = false;
|
bool pendingRemoval = false;
|
||||||
bool pendingInsert = false;
|
bool pendingInsert = false;
|
||||||
|
bool readyDelayStarted = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue