From 1e1f7be7080beb3eef86cbeae638a52dc3c18b97 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 28 Jan 2022 19:08:44 +0300 Subject: [PATCH] Don't scroll reactions dropdown too fast. Fixes #23985. --- .../history/view/history_view_react_button.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/history_view_react_button.cpp b/Telegram/SourceFiles/history/view/history_view_react_button.cpp index 4cac9dc91..dc4a47f91 100644 --- a/Telegram/SourceFiles/history/view/history_view_react_button.cpp +++ b/Telegram/SourceFiles/history/view/history_view_react_button.cpp @@ -46,6 +46,7 @@ constexpr auto kButtonExpandedHideDelay = crl::time(0); constexpr auto kSizeForDownscale = 96; constexpr auto kHoverScaleDuration = crl::time(200); constexpr auto kHoverScale = 1.24; +constexpr auto kMaxReactionsScrollAtOnce = 2; [[nodiscard]] QPoint LocalPosition(not_null e) { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -153,7 +154,13 @@ bool Button::consumeWheelEvent(not_null e) { if (horizontal) { return false; } - const auto shift = delta.y() * (expandUp() ? 1 : -1); + const auto between = st::reactionCornerSkip; + const auto oneHeight = (st::reactionCornerSize.height() + between); + const auto max = oneHeight * kMaxReactionsScrollAtOnce; + const auto shift = std::clamp( + delta.y() * (expandUp() ? 1 : -1), + -max, + max); _scroll = std::clamp(_scroll + shift, 0, scrollMax); _update(_geometry); e->accept();