fix: lazy list view overshoot

This commit is contained in:
2 * r + 2 * t 2026-04-09 17:49:03 +10:00
parent 0682397384
commit 3f72dde918

View file

@ -492,10 +492,22 @@ void LazyListView::relayout() {
}
QRectF LazyListView::effectiveViewport() const {
QRectF vp;
if (m_useCustomViewport)
return m_viewport.adjusted(0, -m_cacheBuffer, 0, m_cacheBuffer);
vp = m_viewport;
else
vp = QRectF(0, m_contentY, width(), height());
return QRectF(0, m_contentY - m_cacheBuffer, width(), height() + 2 * m_cacheBuffer);
// During Flickable overshoot the viewport can extend entirely beyond content bounds,
// causing all delegates to be culled. Clamp so it always overlaps [0, layoutHeight].
if (m_layoutHeight > 0) {
const qreal top = std::min(vp.y(), m_layoutHeight);
const qreal bottom = std::max(vp.y() + vp.height(), 0.0);
if (bottom > top)
vp = QRectF(vp.x(), top, vp.width(), bottom - top);
}
return vp.adjusted(0, -m_cacheBuffer, 0, m_cacheBuffer);
}
std::pair<int, int> LazyListView::computeVisibleRange() const {