From ad9106b815f76bdd14c37e4f88767145a8f53e71 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 16 Mar 2025 18:57:46 +0300 Subject: [PATCH] Added ability to request reach out ratio of swipe. --- Telegram/SourceFiles/ui/controls/swipe_handler.cpp | 9 +++++++++ Telegram/SourceFiles/ui/controls/swipe_handler.h | 1 + 2 files changed, 10 insertions(+) diff --git a/Telegram/SourceFiles/ui/controls/swipe_handler.cpp b/Telegram/SourceFiles/ui/controls/swipe_handler.cpp index 3ec1f32ca6..c49b3d61b4 100644 --- a/Telegram/SourceFiles/ui/controls/swipe_handler.cpp +++ b/Telegram/SourceFiles/ui/controls/swipe_handler.cpp @@ -213,6 +213,7 @@ void SetupSwipeHandler( if (!state->started || state->touch != args.touch) { LOG(("STARTING")); state->started = true; + state->data.reachRatio = 0.; state->touch = args.touch; state->startAt = args.position; state->cursorTop = widget->mapFromGlobal(args.globalCursor).y(); @@ -265,6 +266,14 @@ void SetupSwipeHandler( base::Platform::Haptic(); } else if (state->reached && ratio < kResetReachedOn) { + if (state->finishByTopData.provideReachOutRatio) { + state->animationReach.stop(); + state->animationReach.start( + animationReachCallback, + 1., + 0., + kBounceDuration); + } state->reached = false; } } diff --git a/Telegram/SourceFiles/ui/controls/swipe_handler.h b/Telegram/SourceFiles/ui/controls/swipe_handler.h index 79413091eb..b46e8e3dfc 100644 --- a/Telegram/SourceFiles/ui/controls/swipe_handler.h +++ b/Telegram/SourceFiles/ui/controls/swipe_handler.h @@ -23,6 +23,7 @@ struct SwipeHandlerFinishData { int64 msgBareId = 0; float64 speedRatio = 1.0; bool keepRatioWithinRange = false; + bool provideReachOutRatio = false; }; using Scroll = std::variant<