algo/scrolling: fix offset on removeTarget (#13515)
This commit is contained in:
parent
fe0a202137
commit
ff20cbf89c
1 changed files with 8 additions and 4 deletions
|
|
@ -627,16 +627,20 @@ void CScrollingAlgorithm::removeTarget(SP<ITarget> target) {
|
||||||
|
|
||||||
if (!m_scrollingData->next(DATA->column.lock()) && DATA->column->targetDatas.size() <= 1) {
|
if (!m_scrollingData->next(DATA->column.lock()) && DATA->column->targetDatas.size() <= 1) {
|
||||||
// move the view if this is the last column
|
// move the view if this is the last column
|
||||||
const auto USABLE = usableArea();
|
const auto USABLE = usableArea();
|
||||||
m_scrollingData->controller->adjustOffset(-(USABLE.w * DATA->column->getColumnWidth()));
|
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);
|
DATA->column->remove(target);
|
||||||
|
|
||||||
if (!DATA->column) {
|
if (!DATA->column) {
|
||||||
// column got removed, let's ensure we don't leave any cringe extra space
|
// column got removed, let's ensure we don't leave any cringe extra space
|
||||||
const auto USABLE = usableArea();
|
const auto USABLE = usableArea();
|
||||||
double newOffset = std::clamp(m_scrollingData->controller->getOffset(), 0.0, std::max(m_scrollingData->maxWidth() - USABLE.w, 1.0));
|
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);
|
m_scrollingData->controller->setOffset(newOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue