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

Cannot Scroll down/up when the Carousel is in a ScrollView (Must Click Outside the carousel) #125

Closed
tylerkrett opened this issue Jan 26, 2022 · 28 comments

Comments

@tylerkrett
Copy link

tylerkrett commented Jan 26, 2022

I have a simple image carousel in a scroll view component.

When I want to scroll down past the Carousel the screen will only allow me to animate the carousel.

All movements down/up on a ScrollView will not scroll the page if your finger is on the carousel.

@dohooo
Copy link
Owner

dohooo commented Jan 26, 2022

I'm not sure what you mean. 😶‍🌫️

@dohooo
Copy link
Owner

dohooo commented Jan 26, 2022

Can you give me a video?

@tylerkrett
Copy link
Author

Dohoo I have resolved the issue. Thank you for such a speedy response

@tylerkrett tylerkrett changed the title Cannot Scroll page when Carousel is onit Cannot Scroll down screen when Carousel is onit Jan 26, 2022
@tylerkrett tylerkrett changed the title Cannot Scroll down screen when Carousel is onit Cannot Scroll down/up gestures on Carousel to go down the screen Jan 26, 2022
@dohooo
Copy link
Owner

dohooo commented Jan 26, 2022

Dohoo I have resolved the issue. Thank you for such a speedy response

How did you solve it?

@tylerkrett
Copy link
Author

tylerkrett commented Jan 26, 2022

I decided to use the Carousel in a Modal popup. As it was not letting me scroll down the ScrollView component without touching outside the image carousel.

All gestures within the Carousel will animate the carousel I needed just left and right actions so the ScrollView can be scrolled down or up when your finger is on the carousel.

@tylerkrett
Copy link
Author

Hope that makes sense.

@tylerkrett tylerkrett changed the title Cannot Scroll down/up gestures on Carousel to go down the screen Cannot Scroll down/up when the Carousel is in a ScrollView (Must Click Outside the carousel) Jan 26, 2022
@dohooo
Copy link
Owner

dohooo commented Jan 26, 2022

Hope that makes sense.

Are you in discord? https://discord.gg/cPzr7WMQ

@dohooo
Copy link
Owner

dohooo commented Jan 26, 2022

@tylerkrett try this

<Carousel
    {...}
    panGestureHandlerProps={{
        activeOffsetX: [-10, 10],
    }}
/>

@dohooo
Copy link
Owner

dohooo commented Jan 26, 2022

@tylerkrett try this

<Carousel
    {...}
    panGestureHandlerProps={{
        activeOffsetX: [-10, 10],
    }}
/>

https://docs.swmansion.com/react-native-gesture-handler/docs/gesture-handlers/api/pan-gh/#activeoffsetx

@tylerkrett
Copy link
Author

That worked perfectly. Thank you so much.

@alfredarcifa
Copy link

alfredarcifa commented Oct 26, 2022

@tylerkrett try this

<Carousel
    {...}
    panGestureHandlerProps={{
        activeOffsetX: [-10, 10],
    }}
/>

Hi @dohooo

I use panGestureHandlerProps={{activeOffsetX: [-10, 10],}} and in iOS I haven't any problem.
In Android, I should to use code below:

<ScrollView>
          <GestureHandlerRootView style={{flex: 1}}>
            <Carousel.......>
....

because the drag was locked.
I found an issue in Android with this code, when dragging, at random, the carousel was frozen in a horizontal setting.

@nurhamsah1998
Copy link

I use @alfredarcifa method and the results work well

@sabari-venkatesh
Copy link

panGestureHandlerProps

This was really helpful.. Thanks @dohooo

@AdirTrichter
Copy link

Hey there.
What does the [-10, 10] in the activeOffsetX field means? is it pixels, percent of screen? something else?

@BrodaNoel
Copy link
Contributor

@dohooo this is not a valid fix in 4.0.0-alpha.0

@patrickmycore
Copy link

This is good. But the method "onScrollBegin" still gets triggered when scrolling vertically even after setting

panGestureHandlerProps={{
activeOffsetX: [-10, 10],
}}

@Oleksiiithouse
Copy link

panGestureHandlerProps={{
activeOffsetX: [-20, 20],
failOffsetY: [-20, 20],
}}

@doanhnong
Copy link

work like a champ, thanks

@keenode
Copy link

keenode commented Apr 18, 2024

Thank you, this worked for me!

@cbdeveloper
Copy link

I was using it inside a Modal on Android. So wrapping the Modal children in GestureHandlerRootView was also necessary for me.

https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation/#usage-with-modals-on-android

This is what is working for me:

panGestureHandlerProps={{
  activeOffsetX: [-5, 5],
  failOffsetY: [-5, 5]
}}

Note: using "react-native-reanimated-carousel": "3.5.1",

@Arjun059
Copy link

@dohooo thanks

@qwertychouskie
Copy link

@dohooo this is not a valid fix in 4.0.0-alpha.0

#465 (comment)

@qwertychouskie
Copy link

On iOS, when I start a horizontal scroll, it blocks starting a vertical scroll until the finger is removed and a new gesture started. However, on Android, if the finger moves up/down slightly during the horizontal scroll, the horizontal scroll is immediately released and it starts scrolling vertically. Is there a fix for this behavior?

(Using 4.0.0-alpha12 due to #509 / #625)

@qwertychouskie
Copy link

Also, scrolling up and down doesn't work at all on web. Any ideas there? Is it worth opening a new bug report?

@Oleksiiithouse
Copy link

Also, scrolling up and down doesn't work at all on web. Any ideas there? Is it worth opening a new bug report?

Just downgrade to 3.x version, it has less bugs.
Versions 4.x are still alpha, of course it is buggy

@qwertychouskie
Copy link

Also, scrolling up and down doesn't work at all on web. Any ideas there? Is it worth opening a new bug report?

Just downgrade to 3.x version, it has less bugs. Versions 4.x are still alpha, of course it is buggy

I can't, due to #509 / #625

@Oleksiiithouse
Copy link

@qwertychouskie
I have a long experience with this library. Any of library versions are not good enough, each has its pros and cons.
Below I paste versions of dependencies that by working together have the less problems ever possible:

"react-native-gesture-handler": "^2.8.0",
"react-native-reanimated": "^2.14.4",
"react-native-reanimated-carousel": "^3.5.1".

With these dependencies everything works on web and native.
The only minus is that v3.5.1 doesn't have all props that mentioned in the docs. For me it was not a huge problem, for everything I found a workaround.

@tarikfp
Copy link

tarikfp commented Nov 15, 2024

If anyone wondering solution for 4.0.0-alpha.10 version, here it is:

 onConfigurePanGesture={(g) => {
    "worklet"
    // Disable vertical gestures
    g.activeOffsetY([-999999, 999999])
    // Enable horizontal gestures with a small threshold
    g.activeOffsetX([-20, 20])
    })
  }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests