Problem with slider inside BottomSheet on Android

See original GitHub issue

Hi, I’ve got problem with slider inside BottomSheet. Everything works fine on iOS, but on Android I can’t use horizontal scrolling. I had more problems in android (because I’m using ScrollView inside BottomSheet), but with this thread (https://github.com/osdnk/react-native-reanimated-bottom-sheet/issues/16) I resolved most problems without that one. Slider (react-native-snap-carousel) works only when I set enabledContentGestureInteraction={false} but then I lose major functionality.

Is there any solution for that? Does somebody use another slider with this library? (but I’m guessing this is problem occurring with BottomSheet) I saw that what I need is in TODO section probably, but maybe someone has some idea, because lib is great 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
tuanngocptncommented, Feb 25, 2021

I have the same problem when try using ScrollView with horizontal inside BottomSheet And I solve it after change import from react-native to react-native-gesture-handler. 👯 👯 👯 👯 👯

1reaction
DonWasylcommented, Dec 23, 2019

Ok I found temporary and working solution 😃

In my example I’m using reanimated-bottom-sheet with react-native-snap-carousel inside ScrollView.

I had to add state which we will be using to enable/disable gesture interaction and enable it during onTouchStart on container with that element.

Simple example

this.state = {
   isHorizontalScrollingEnabled: false,
}

--

 _handleHorizontalScrollingEnable = () => {
  this.setState({
    isHorizontalScrollingEnabled: true,
  });
};

  _handleHorizontalScrollingDisable = () => {
  this.setState({
    isHorizontalScrollingEnabled: false,
  });
};

--

<BottomSheet
  [...]
  enabledGestureInteraction={!this.state.isHorizontalScrollingEnabled}
  renderContent={() => (
    <PanGestureHandler
      activeOffsetY={5}
      failOffsetY={-5}
      onGestureEvent={this._onScrollDown}
      [...]
    >
      <ScrollView [...]>
        <View onTouchStart={this._handleHorizontalScrollingEnable}>
           // Our part of code with horizontal scrolling - in my case react-native-snap-carousel
        </View>
      </ScrollView>
    </PanGestureHandler>
  )}
/>

I didn’t check if that work with native scroll, but with react-native-snap-carousel In renderContent section works 😃 PanGestureHandler is the approach from there: https://github.com/software-mansion/react-native-gesture-handler/issues/420#issuecomment-457499442 and in onScrollDown function i disabling horizontal scrolling.

Maybe that will be helpful for someone

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show Range Slider inside flutter Bottom Sheet popup alert
flutter #flutterapp #fluttersliderWas this Tutorial helpful? Spread Motivation on me by supporting https://paypal.me/RajatPalankar Hi Guys, ...
Read more >
android - BottomSheetDialogFragment - Allow scrolling child
The problem is, I want to disable the drag close function of the BottomSheetDialogFragment as long as the RecyclerView is not scrolled up...
Read more >
Make your BottomSheetDialog noncancelable - beta - Medium
Problem comes: you cannot make a persistent bottom sheet by using the Dialog#setCancelable or DialogFragment#setCancelable method, so that your bottom sheet ...
Read more >
Slider - Android Developers
A widget that allows picking a value within a given range by sliding a thumb along a horizontal line. android:value : Optional.
Read more >
I am using @gorhom/bottomsheet and when i expand ... - Reddit
First problem, you need to use the bottom sheet provider upper in the component tree, let's say on your app.js it should come...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found