diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 98fa217738..87fb2e806e 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -7588,6 +7588,7 @@ void HistoryWidget::startCollapseAnimation(int height, int itemTop) { && itemTop <= gap.absY + gap.currentHeight)) { gap.startHeight += height; gap.currentHeight += height; + gap.originalHeight += height; merged = true; break; } @@ -7595,6 +7596,7 @@ void HistoryWidget::startCollapseAnimation(int height, int itemTop) { gap.absY = itemTop; gap.startHeight += height; gap.currentHeight += height; + gap.originalHeight += height; merged = true; break; } @@ -7604,6 +7606,7 @@ void HistoryWidget::startCollapseAnimation(int height, int itemTop) { .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; }); @@ -7660,8 +7663,13 @@ void HistoryWidget::syncCollapseGapsToList() { } auto gaps = std::vector(); gaps.reserve(_collapseGaps.size()); + auto cumulativeOriginal = 0; for (const auto &g : _collapseGaps) { - gaps.push_back({ .absY = g.absY, .height = g.currentHeight }); + gaps.push_back({ + .absY = g.absY - cumulativeOriginal, + .height = g.currentHeight, + }); + cumulativeOriginal += g.originalHeight; } _list->setCollapseGaps(gaps); } diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 22ca69b46e..21a9072e7d 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -949,6 +949,7 @@ private: int absY = -1; int startHeight = 0; int currentHeight = 0; + int originalHeight = 0; }; std::vector _collapseGaps; Ui::Animations::Simple _collapseAnimation;