[thanos] Used originalHeight for merge adjacency and ordered insertion.

This commit is contained in:
23rd
2026-04-09 23:37:18 +03:00
parent e3e2d8ba56
commit 3e416e0bf6
2 changed files with 10 additions and 16 deletions
+10 -15
View File
@@ -7583,9 +7583,9 @@ void HistoryWidget::startCollapseAnimation(int height, int itemTop) {
auto merged = false;
for (auto &gap : _collapseGaps) {
if (gap.absY + gap.currentHeight == itemTop
if (gap.absY + gap.originalHeight == itemTop
|| (gap.absY <= itemTop
&& itemTop <= gap.absY + gap.currentHeight)) {
&& itemTop <= gap.absY + gap.originalHeight)) {
gap.startHeight += height;
gap.currentHeight += height;
gap.originalHeight += height;
@@ -7602,14 +7602,17 @@ void HistoryWidget::startCollapseAnimation(int height, int itemTop) {
}
}
if (!merged) {
_collapseGaps.push_back({
const auto it = std::lower_bound(
_collapseGaps.begin(),
_collapseGaps.end(),
itemTop,
[](const auto &gap, int top) { return gap.absY < top; });
_collapseGaps.insert(it, {
.absY = itemTop,
.startHeight = height,
.currentHeight = height,
.originalHeight = height,
});
std::sort(_collapseGaps.begin(), _collapseGaps.end(),
[](const auto &a, const auto &b) { return a.absY < b.absY; });
}
syncCollapseGapsToList();
@@ -7618,7 +7621,6 @@ void HistoryWidget::startCollapseAnimation(int height, int itemTop) {
const auto scrollAdjust = std::min(height, aboveViewport);
if (scrollAdjust > 0) {
synteticScrollToY(scrollTop + scrollAdjust);
_collapseScrollCompensation += scrollAdjust;
}
auto totalHeight = 0;
@@ -7652,20 +7654,13 @@ void HistoryWidget::collapseAnimationCallback() {
}
if (totalDelta != 0) {
const auto scrollTop = _scroll->scrollTop();
syncCollapseGapsToList();
if (_collapseScrollCompensation > 0) {
const auto scrollReverse = std::min(
totalDelta,
_collapseScrollCompensation);
_collapseScrollCompensation -= scrollReverse;
const auto scrollTop = _scroll->scrollTop();
synteticScrollToY(std::max(scrollTop - scrollReverse, 0));
}
synteticScrollToY(std::max(scrollTop - totalDelta, 0));
}
if (!_collapseAnimation.animating()) {
_collapseGaps.clear();
_collapseScrollCompensation = 0;
if (_list) {
_list->setCollapseGaps({});
}
@@ -953,7 +953,6 @@ private:
};
std::vector<CollapseGapState> _collapseGaps;
Ui::Animations::Simple _collapseAnimation;
int _collapseScrollCompensation = 0;
void collapseAnimationCallback();
void syncCollapseGapsToList();