From 0e40700df20c08093158e4ac2d82f98bcb7f1567 Mon Sep 17 00:00:00 2001 From: Nikolai Nechaev Date: Wed, 1 Jan 2025 11:28:05 +0300 Subject: [PATCH] Notifications: fix the use of `.start()`/`.change()` animation methods 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. --- .../SourceFiles/window/notifications_manager_default.cpp | 7 ++++++- Telegram/lib_ui | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index c46b013d6e29f..9637a18c72d68 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -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); } diff --git a/Telegram/lib_ui b/Telegram/lib_ui index da44ac82a99ec..1da57c5848448 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit da44ac82a99ec05d7091eaaf6ae96a63bbae3714 +Subproject commit 1da57c5848448b433948a026f8a887942be00dd9