Skip to content

Commit

Permalink
Notifications: fix the use of .start()/.change() animation methods
Browse files Browse the repository at this point in the history
When a notification is to stop hiding (i.e., fade in), it is support to
start fading in from whatever opacity it has at the moment, not from 0.
Fixed that part to call the `.change()` method instead of `.start()` and
added a clarification comment.

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). Left the call to `.start()` and added a
clarification comment.
  • Loading branch information
kolayne committed Jan 2, 2025
1 parent 62589d3 commit a00fac7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,17 @@ void Widget::hideStop() {
if (_hiding) {
_hiding = false;
_hidingDelayed = {};
_a_opacity.start([this] { opacityAnimationCallback(); }, 0., 1., st::notifyFastAnim);
// Using `.change` instead of `.start` because we want to start
// animation from the current opacity level, not blink it.
_a_opacity.change(1., st::notifyFastAnim);
}
}

void Widget::hideAnimated(float64 duration, const anim::transition &func) {
_hiding = true;
// Using `.start` instead of `.change` because we want to ensure the notification
// is fully restored before starting to hide it (it may not have been restored if
// the cursor has passed through it too quickly, see #28811).
_a_opacity.start([this] { opacityAnimationCallback(); }, 1., 0., duration, func);
}

Expand Down
2 changes: 1 addition & 1 deletion Telegram/lib_ui
Submodule lib_ui updated 1 files
+15 −4 ui/effects/animations.h

0 comments on commit a00fac7

Please sign in to comment.