From 998d71e5a7cff49ac8caa0f5ca82616237e0d038 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Mon, 8 Feb 2021 18:40:55 +0100 Subject: [PATCH] Remove item move animation on view resize This commit removes an animation that happens when the view is resized. Before this commit, whenever the geometry of the view changed, the items in the view drifted towards their new position in the layout after a 300 ms delay. It would look like the items are slow to find their position. This commit simply moves them to their new position in an instant which will abort any ongoing move animations. --- src/kitemviews/kitemlistview.cpp | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index 96c337de39..56cede2fdf 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -372,29 +372,12 @@ void KItemListView::setGeometry(const QRectF& rect) m_itemSize.height()); m_layouter->setItemSize(dynamicItemSize); } - - // Triggering a synchronous layout is fine from a performance point of view, - // as with dynamic item sizes no moving animation must be done. - m_layouter->setSize(newSize); - doLayout(NoAnimation); - } else { - const bool animate = !changesItemGridLayout(newSize, - m_layouter->itemSize(), - m_layouter->itemMargin()); - m_layouter->setSize(newSize); - - if (animate) { - // Trigger an asynchronous relayout with m_layoutTimer to prevent - // performance bottlenecks. If the timer is exceeded, an animated layout - // will be triggered. - if (!m_layoutTimer->isActive()) { - m_layoutTimer->start(); - } - } else { - m_layoutTimer->stop(); - doLayout(NoAnimation); - } } + + m_layouter->setSize(newSize); + // We don't animate the moving of the items here because + // it would look like the items are slow to find their position. + doLayout(NoAnimation); } qreal KItemListView::verticalPageStep() const @@ -1840,9 +1823,6 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha // prevents a "move animation mess" when inserting several ranges in parallel. applyNewPos = !moveWidget(widget, newPos); } - } else if (!itemsRemoved && !itemsInserted && !wasHidden) { - // The size of the view might have been changed. Animate the moving of the position. - applyNewPos = !moveWidget(widget, newPos); } } else { m_animation->stop(widget);