From c29d78ac0d0aaa07527db328a6bcc99fc99dda40 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 16 Mar 2025 19:00:59 +0300 Subject: [PATCH] Added ability to provide reach ratio speed to swipe. --- Telegram/SourceFiles/ui/controls/swipe_handler.cpp | 8 ++++++-- Telegram/SourceFiles/ui/controls/swipe_handler.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/ui/controls/swipe_handler.cpp b/Telegram/SourceFiles/ui/controls/swipe_handler.cpp index c49b3d61b4..f5c3cb60ce 100644 --- a/Telegram/SourceFiles/ui/controls/swipe_handler.cpp +++ b/Telegram/SourceFiles/ui/controls/swipe_handler.cpp @@ -262,7 +262,9 @@ void SetupSwipeHandler( animationReachCallback, 0., 1., - kBounceDuration); + state->finishByTopData.reachRatioDuration + ? state->finishByTopData.reachRatioDuration + : kBounceDuration); base::Platform::Haptic(); } else if (state->reached && ratio < kResetReachedOn) { @@ -272,7 +274,9 @@ void SetupSwipeHandler( animationReachCallback, 1., 0., - kBounceDuration); + state->finishByTopData.reachRatioDuration + ? state->finishByTopData.reachRatioDuration + : kBounceDuration); } state->reached = false; } diff --git a/Telegram/SourceFiles/ui/controls/swipe_handler.h b/Telegram/SourceFiles/ui/controls/swipe_handler.h index b46e8e3dfc..6d3f796b1e 100644 --- a/Telegram/SourceFiles/ui/controls/swipe_handler.h +++ b/Telegram/SourceFiles/ui/controls/swipe_handler.h @@ -22,6 +22,7 @@ struct SwipeHandlerFinishData { Fn callback; int64 msgBareId = 0; float64 speedRatio = 1.0; + crl::time reachRatioDuration = 0; bool keepRatioWithinRange = false; bool provideReachOutRatio = false; };