Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Augment the hitSlop or prevent parent gesture listener to react around slider #296

Open
zabojad opened this issue Aug 2, 2021 · 20 comments
Labels
bug report Something isn't working platform: Android Issue related to Android platform

Comments

@zabojad
Copy link

zabojad commented Aug 2, 2021

I'm using a slider within a swiper and it's quite hard to slide the slider without triggering the swiper.

How could I improve that situation ?

Is there some kind of hitSlop prop equivalent on the slider?

If not, how could I workaround this problem?

@zabojad zabojad added the bug report Something isn't working label Aug 2, 2021
@zabojad
Copy link
Author

zabojad commented Aug 3, 2021

Note that it is actually a problem on Android, not on iOS...

@BartoszKlonowski BartoszKlonowski added the platform: Android Issue related to Android platform label Aug 13, 2021
@zabojad
Copy link
Author

zabojad commented Aug 20, 2021

Does anyone have a solution? I'm still looking for it...

@BartoszKlonowski
Copy link
Member

@zabojad Can you provide a minimal example or a part of your code?
I will take a look into that.

@zabojad
Copy link
Author

zabojad commented Aug 20, 2021

hey @BartoszKlonowski ! Thanks for taking the time to help me.

Here is a reproducer : https://snack.expo.dev/5jW86cV70

I've not included the react-native-swiper dependency because it is actually just a ScrollView...

So let me recap the issue : when nested in an horizontal ScrollView, there is no way to give the priority to the react-native-slider instance for touch events... This happens only on Android. It's fine on iOS.

@BartoszKlonowski
Copy link
Member

@zabojad That is a good example, thank you!
As I can see it is possible to reach the slider with a touch event, but dragging is captured by a parent.
Let me take some time to dig in and I will come back to you.

@zabojad
Copy link
Author

zabojad commented Aug 23, 2021

Hej @BartoszKlonowski ! Did you find anything regarding this issue, by any chance?

@zabojad
Copy link
Author

zabojad commented Aug 27, 2021

I've opened another issue in RN issue tracker.

@BartoszKlonowski
Copy link
Member

@zabojad Sorry for a delay, but yes, I found that this behavior is caused by a native layout structure and is typical for a native Android solutions.
I also found some code samples that would need to be applied to this library, but we will need to spend some time to implement this.

You created an issue in RN repository - let's see if someone will provide you with a decent solution or at least workaround, but in the worst case let's accept if the issue will be closed as the responsibility for this feature is most probably on our side.

@zabojad
Copy link
Author

zabojad commented Aug 27, 2021

@BartoszKlonowski thank you for your answer. I just checked out the Android sources of this module. Can you please describe what should be done exactly?

@zabojad
Copy link
Author

zabojad commented Sep 3, 2021

@BartoszKlonowski sorry to ask you again, but I could probably help on this topic if you describe me what has to be done...

@BartoszKlonowski
Copy link
Member

@zabojad I was trying to find a way that would not require manipulating the ScrollView from a SeekBar, because from my research it turns out that what needs to be done is to block or revert a progress of ScrollView each time the SeekBar is changed.
But the thing is that I can't find a way to access the parent ScrollView from a native implementation of SeekBar View Manager - that's the case.

@zabojad
Copy link
Author

zabojad commented Sep 28, 2021

But the thing is that I can't find a way to access the parent ScrollView from a native implementation of SeekBar View Manager - that's the case.

@BartoszKlonowski Could we somehow pass the slider a ref to the scrollview from js?

@zabojad
Copy link
Author

zabojad commented Oct 7, 2021

@BartoszKlonowski sorry to disturb you again, could you share the details of what you've found out so that I could try to continue searching for a solution?

@BartoszKlonowski
Copy link
Member

@zabojad I'm back, sorry.
I believe that this SO answer described the best what should be done.
I think that we should somehow force the View to use this requestDisallowInterceptTouchEvent.

@tushar-singhal
Copy link

was anyone able to fix this ? I am facing the same issue

@ykvarts
Copy link

ykvarts commented Dec 26, 2021

Solution that works for me, added this as a slider prop
onResponderGrant={() => true}

@blazk0
Copy link

blazk0 commented May 26, 2022

@ykvarts solution didn't work for me :/

@blazk0
Copy link

blazk0 commented May 26, 2022

In my case, the parent is PanGestureHandler which was overriding the Slider gesture.
Giving a minDist={20} to it fixed it for me

@kien-nt0306
Copy link

@ykvarts solution didn't work for me :/

Solution that works for me, added this as a slider prop onResponderGrant={() => true}

thank you it works fine for me now

@za-rakib
Copy link

za-rakib commented Sep 9, 2024

In my case, the parent is PanGestureHandler which was overriding the Slider gesture. Giving a minDist={20} to it fixed it for me

Thank you so much for your solution —it worked perfectly for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something isn't working platform: Android Issue related to Android platform
Projects
Status: To be analyzed
Development

No branches or pull requests

7 participants