From ff20cbf89c68a87b12c0cd3453ac13d7c7197da5 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Mon, 2 Mar 2026 21:23:24 +0000 Subject: [PATCH] algo/scrolling: fix offset on removeTarget (#13515) --- .../algorithm/tiled/scrolling/ScrollingAlgorithm.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index 94e658d3..3b5dca4a 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -627,16 +627,20 @@ void CScrollingAlgorithm::removeTarget(SP target) { if (!m_scrollingData->next(DATA->column.lock()) && DATA->column->targetDatas.size() <= 1) { // move the view if this is the last column - const auto USABLE = usableArea(); - m_scrollingData->controller->adjustOffset(-(USABLE.w * DATA->column->getColumnWidth())); + const auto USABLE = usableArea(); + const bool isPrimaryHoriz = m_scrollingData->controller->isPrimaryHorizontal(); + const double usablePrimary = isPrimaryHoriz ? USABLE.w : USABLE.h; + m_scrollingData->controller->adjustOffset(-(usablePrimary * DATA->column->getColumnWidth())); } DATA->column->remove(target); if (!DATA->column) { // column got removed, let's ensure we don't leave any cringe extra space - const auto USABLE = usableArea(); - double newOffset = std::clamp(m_scrollingData->controller->getOffset(), 0.0, std::max(m_scrollingData->maxWidth() - USABLE.w, 1.0)); + const auto USABLE = usableArea(); + const bool isPrimaryHoriz = m_scrollingData->controller->isPrimaryHorizontal(); + const double usablePrimary = isPrimaryHoriz ? USABLE.w : USABLE.h; + const double newOffset = std::clamp(m_scrollingData->controller->getOffset(), 0.0, std::max(m_scrollingData->maxWidth() - usablePrimary, 1.0)); m_scrollingData->controller->setOffset(newOffset); }