diff --git a/ui/widgets/elastic_scroll.cpp b/ui/widgets/elastic_scroll.cpp index 4ae5bd9..9a5b7fa 100644 --- a/ui/widgets/elastic_scroll.cpp +++ b/ui/widgets/elastic_scroll.cpp @@ -412,7 +412,8 @@ void ElasticScroll::touchDeaccelerate(int32 elapsed) { } void ElasticScroll::overscrollReturn() { - _ignoreMomentum = _overscrollReturning = true; + _overscrollReturning = true; + _ignoreMomentumFromOverscroll = _overscroll; if (overscrollFinish()) { _overscrollReturnAnimation.stop(); return; @@ -647,20 +648,19 @@ bool ElasticScroll::handleWheelEvent(not_null e, bool touch) { const auto guard = gsl::finally([&] { _lastScroll = now; }); - if (_ignoreMomentum) { - if (momentum) { - if (!_overscrollReturnAnimation.animating()) { - return true; - } - } else { - _ignoreMomentum = false; - } - } const auto pixels = ScrollDelta(e); auto delta = _vertical ? -pixels.y() : pixels.x(); if (std::abs(_vertical ? pixels.x() : pixels.y()) >= std::abs(delta)) { delta = 0; } + if (_ignoreMomentumFromOverscroll) { + if (!momentum) { + _ignoreMomentumFromOverscroll = 0; + } else if (!_overscrollReturnAnimation.animating() + && !base::OppositeSigns(_ignoreMomentumFromOverscroll, delta)) { + return true; + } + } if (phase == Qt::NoScrollPhase) { if (_overscroll == currentOverscrollDefault()) { tryScrollTo(_state.visibleFrom + delta); diff --git a/ui/widgets/elastic_scroll.h b/ui/widgets/elastic_scroll.h index 50d6111..af74ec4 100644 --- a/ui/widgets/elastic_scroll.h +++ b/ui/widgets/elastic_scroll.h @@ -239,6 +239,7 @@ private: crl::time _lastScroll = 0; TouchScrollState _touchScrollState = TouchScrollState::Manual; int _overscrollAccumulated = 0; + int _ignoreMomentumFromOverscroll = 0; bool _touchDisabled : 1 = false; bool _touchScroll : 1 = false; bool _touchPress : 1 = false; @@ -249,7 +250,6 @@ private: bool _widgetAcceptsTouch : 1 = false; bool _disabled : 1 = false; bool _dirtyState : 1 = false; - bool _ignoreMomentum : 1 = false; bool _overscrollReturning : 1 = false; Fn)> _customWheelProcess;