From 6cce81231ae9c5f872d5288b3d9633801b10ccb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=CC=81o=20Natan?= Date: Thu, 26 Sep 2024 06:29:16 +0300 Subject: [PATCH] Further improve scroll gesture handling Closes #580 --- .../Private/LNPopupController.mm | 24 ++++++++++++++++--- .../LNPopupInteractionPanGestureRecognizer.m | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/LNPopupController/LNPopupController/Private/LNPopupController.mm b/LNPopupController/LNPopupController/Private/LNPopupController.mm index 8eff285..8df7ab5 100644 --- a/LNPopupController/LNPopupController/Private/LNPopupController.mm +++ b/LNPopupController/LNPopupController/Private/LNPopupController.mm @@ -843,15 +843,33 @@ - (void)_popupBarPresentationByUserPanGestureHandler_changed:(UIPanGestureRecogn } } -- (void)_popupBarPresentationByUserPanGestureHandler_endedOrCancelled:(UIPanGestureRecognizer*)pgr +- (BOOL)_shouldStopEndOrCancelledOnUnknownGestureRecognizerOrHorizontalScroll:(UIPanGestureRecognizer*)pgr { - if(_dismissGestureStarted == true && pgr != _popupContentView.popupInteractionGestureRecognizer) + if(pgr == _popupContentView.popupInteractionGestureRecognizer) { - return; + return NO; + } + + UIScrollView* possibleScrollView = (id)pgr.view; + if([possibleScrollView isKindOfClass:UIScrollView.class] == NO) + { + return YES; } + return possibleScrollView._ln_hasHorizontalContent; +} + +- (void)_popupBarPresentationByUserPanGestureHandler_endedOrCancelled:(UIPanGestureRecognizer*)pgr +{ LNPopupInteractionStyle resolvedStyle = _LNPopupResolveInteractionStyleFromInteractionStyle(_containerController.popupInteractionStyle); + if(_dismissGestureStarted == true && [self _shouldStopEndOrCancelledOnUnknownGestureRecognizerOrHorizontalScroll:pgr]) + { + _dismissGestureStarted = NO; + + return; + } + if(_dismissGestureStarted == YES) { LNPopupPresentationState targetState = _stateBeforeDismissStarted; diff --git a/LNPopupController/LNPopupController/Private/LNPopupInteractionPanGestureRecognizer.m b/LNPopupController/LNPopupController/Private/LNPopupInteractionPanGestureRecognizer.m index 9450ada..f987dea 100644 --- a/LNPopupController/LNPopupController/Private/LNPopupInteractionPanGestureRecognizer.m +++ b/LNPopupController/LNPopupController/Private/LNPopupInteractionPanGestureRecognizer.m @@ -88,7 +88,7 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogni return YES; } - if([otherGestureRecognizer.view isKindOfClass:UIScrollView.class] && [(UIScrollView*)otherGestureRecognizer.view _ln_hasVerticalContent] == NO) + if([otherGestureRecognizer.view isKindOfClass:UIScrollView.class] && [(UIScrollView*)otherGestureRecognizer.view _ln_hasVerticalContent] == NO && [(UIScrollView*)otherGestureRecognizer.view _ln_hasHorizontalContent] == NO) { return YES; }