oliviertassinari / react-swipeable-views

A React component for swipeable views. :snowflake:
https://react-swipeable-views.com/
MIT License
4.46k stars 479 forks source link

React-swipeable-views and a carousel as child #474

Open JustDevelop opened 5 years ago

JustDevelop commented 5 years ago

I am trying to use React-swipeable-views as a main wrapper of my views. Inside this views, I want to display a carousel, which is also swipeable. The problem is: I can't swipe the carousel without swiping the whole view.

A solution: I hope I am able to add a className to the child carousel inside the view. This was the swipe actions inside this div can be disabled? Something like this would be awesome (or another way is the way 2 nested swipeable views work, but I can't manage to display multiple views at once and create a carousel with react-swipeable-views).

I hope someone can help me, since I don't know how to solve this problem.

Thanks in advance ;)

vojtech-osvald commented 5 years ago

Hello, I had similar problem and this is how I solved it. I put the inner carousel in a div that looks something like this

<div onmousedown="event.stopPropagation()" onmouseup="event.stopPropagation()">
    <carousel.../>
</div>

Therefore the mouse events remain in the inner carousel and swipeable view does not do anything.

Hope this helps, best regards, Vojtech