fix: handle multiple gesture recognizers#1512
Conversation
|
@kkafar I would like to take the opportunity to talk about a general issue with multiple recognizers. This patch allows us to use https://github.com/callstack/react-native-pager-view and https://github.com/satya164/react-native-tab-view in a way that also Twitter does. While having Do you think there is any chance to have this somehow supported OOTB by RNS? I understand that RNS would most likely not add ReactNativePageView as a dependency, but maybe you are aware of a more generic way to have this supported. Here is a video demonstrating what this patch does. Without this patch, fullScreenGestureEnabled would just take over and break swiping. Using only edge swiping, it will even break and make it impossible to swipe back. The edge issue has been fixed lately but fullScreen need this patch. RPReplay_Final1657015453.mp4 |
dc86479 to
215bbd2
Compare
some cases Now screen stack gesture recognizers do not receive events when gestures are disabled or there is no screen to navigate to
|
I pulled in your changes and the bugs I reported are gone. Unfortunately, it did not "fix" the Tab Pager Fullscreen Swiping, so I will need to patch it |
|
Hi @hirbod |
|
I totally understand that. I was not requesting RNPageView dependency, I was more likely asking if you have an idea of a generic solution, but I just think that it is too custom. For now we will need to patch this on every release then. |
WoLewicki
left a comment
There was a problem hiding this comment.
LGTM, but logic gets more complicated with each fix 😅
|
I just upgraded to SDK 46 (custom dev client) and it looks like this change messes around with plenty of gestures. Like I can't even close Gorhoms Bottom Sheet anymore because the fullscreenSwipe messes with it. I still have to investigate but it specially has issues with ScrollViews and FlatLists |
|
False alarm. It was RNGH which caused the issue. We filed an issue there |
@kkafar Is this something that is still planned or has this been solved? I'm trying to figure out how I can swipe away a vertical modal that has a scrollview in it. |
|
@kkafar Sorry to be annoying with this, but I would like to follow up on my question. I'd just like to know if the feature you mentioned (quoted in my previous comment) is planned in a recent future? Thx |
|
HI @timurridjanovic, |
|
@kkafar Thank you! |
@kkafar do you know if there's any workaround possible to implement this behaviour currently? The "swipe down to dismiss" feature works with those options: But i can't make it work when there's a scrollview that swallows the gesture events... Is there any way to propagate those events manually when i know that the scrollOffset is 0? Or do you have any idea on how you would implement this? I might take a crack at it. |
|
Hey @Madumo and others affected in this PR. I would check whether scollview is attached. If it is the case - check its offset. If it is < / <= than some threshold (0?) allow our gesture recognizer to receive the event (recognise simultaneously with the scroll view gesture recognizer). Then in gesture handling method (I do not recall whether it is currently overrided) trigger screen dismissal if the event comes with y offset > 0. Any PR is welcome, however as you brought it to my attention I might take crack at it once I finish my current task. Edit: I would also see this behaviour exposed as separate prop. |
|
Hey @kkafar, I work with @Madumo and we looked into fixing this issue. Following your recommendations, we ended up with this patch that seems to be fixing the problem for us: https://gist.github.com/RaphBlanchet/d260376370b39ee5c9ba7e4c45bcd939 We can now drag the screen down to dismiss it, even if the gesture is from the underlying ScrollView. We are even able to keep the bounces of the ScrollView by cancelling the ScrollView's gesture when we detect we are doing a dismiss. If this patch looks good to you, I will do a PR to include this fix! Also, regarding the flag you mentioned, I think that checking the already existing |
|
@RaphBlanchet, took a look at the gist and it looks like it could work. Definitely open up a PR!
We can think about treating it like that :D But will see when the PR is open & have some time to test it. |
Description
Fixes #1510
Fixed & improved
RNSScreenStackViewlogic regardingUIGestureRecognizerDelegateprotocol.Changes
gestureRecognizer:shouldReceiveEvent:. Events for particular gesture recognisers are now filtered beforegestureRecognizerShouldBeginmethod is called.UIScreenEdgePanGestureRecognizermust fail for scroll view gesture recogniser to begin.fullScreenSwipeEnabled == truescroll view gesture recogniser is prioritised before ourRNSPanGestureRecognizer.gestureRecognzerShouldBegin.Now, when adding another gesture recogniser with screen stack as delegate one must make sure that events are properly filtered.
Screenshots / GIFs
Here you can add screenshots / GIFs documenting your change.
You can add before / after section if you're changing some behavior.
Before
As on screen recordings attached in #1510
After
Screen.Recording.2022-07-06.at.11.39.02.mov
Screen.Recording.2022-07-06.at.11.41.16.mov
Test code and steps to reproduce
Test1072Checklist