Notifications: stop fading in before starting to fade out

When a notification is to start hiding (i.e., fade out), it is supposed
to start fading out from the maximum opacity, even if it was not fully
restored (which only happens if the cursor passed through the
notification too quickly). Thus, call `.stop()` for the previous
animation, if any, before `.start()`ing the next animation.
This commit is contained in:
Nikolai Nechaev 2025-01-01 11:28:05 +03:00 committed by John Preston
parent 7f6221b409
commit 03af444735

View file

@ -549,6 +549,10 @@ void Widget::hideStop() {
void Widget::hideAnimated(float64 duration, const anim::transition &func) {
_hiding = true;
// Stop the previous animation so as to make sure that the notification
// is fully restored before hiding it again.
// Relates to https://github.com/telegramdesktop/tdesktop/issues/28811.
_a_opacity.stop();
_a_opacity.start([this] { opacityAnimationCallback(); }, 1., 0., duration, func);
}