Fix text appearing height animation.

This commit is contained in:
John Preston
2026-04-21 16:26:32 +07:00
parent 4f89780cfe
commit f34e62f24a
2 changed files with 9 additions and 8 deletions
@@ -5153,7 +5153,7 @@ int Message::resizeContentGetHeight(int newWidth) {
}
if (!mediaDisplayed && bubble && hasVisibleText()) {
const auto probeTextWidth = bubbleTextWidth(contentWidth);
[[maybe_unused]] const auto probeHeight = textHeightFor(probeTextWidth);
[[maybe_unused]] const auto probe = textHeightFor(probeTextWidth);
if (!Get<TextAppearing>()) {
const auto use = textRealWidth();
if (use > 0) {
@@ -5439,7 +5439,7 @@ bool Message::textAppearCheckLine(not_null<TextAppearing*> appearing) {
if (appearing->heightAnimation.animating()
|| !appearing->widthAnimation.animating()
|| left <= duration) {
textAppearStartHeightAnimation(appearing);
textAppearStartHeightAnimation(appearing, targetHeight);
}
}
}
@@ -5477,13 +5477,12 @@ void Message::textAppearStartWidthAnimation(
}
void Message::textAppearStartHeightAnimation(
not_null<TextAppearing*> appearing) {
not_null<TextAppearing*> appearing,
int targetHeight) {
Expects(appearing->use);
const auto from = appearing->shownHeight;
const auto to
= appearing->targetHeight
= textAppearTargetHeight(appearing);
const auto to = appearing->targetHeight = targetHeight;
const auto duration = appearing->finalizing
? kLineHeightAppearFinalDuration
: kLineHeightAppearDuration;
@@ -5496,7 +5495,7 @@ int Message::textAppearTargetHeight(
not_null<TextAppearing*> appearing) const {
const auto next = appearing->shownLine + 1;
const auto lines = int(appearing->lines.size());
if (next >= lines) {
if (next + 1 >= lines) {
return appearing->lines.back().bottom;
}
const auto &line = appearing->lines[next];
@@ -397,7 +397,9 @@ private:
bool textAppearValidate(not_null<TextAppearing*> appearing);
bool textAppearCheckLine(not_null<TextAppearing*> appearing);
void textAppearStartWidthAnimation(not_null<TextAppearing*> appearing);
void textAppearStartHeightAnimation(not_null<TextAppearing*> appearing);
void textAppearStartHeightAnimation(
not_null<TextAppearing*> appearing,
int targetHeight);
void textAppearWidthCallback();
void textAppearHeightCallback();
[[nodiscard]] int textAppearTargetHeight(