-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Upon tap, Carousel does not execute onPress method for custom parent TouchableOpacity. #476
Comments
Oh, and yes I have tried different orders of nesting Views and Opacities in the component hierarchy, but Carousel remains immune to being a child of an Opacity. |
Hi @irajwani, Can you please provide a Snack example in which the issue can be reproduced? |
Yes, please give me a little bit of time. |
I apologize for the delay. Here's a working example to highlight the issue. |
I'm facing same issue. Did you get any workaround for this? Thanks & regards |
I have not yet. hmm but perhaps positioning the carousel absolutely under a touchableopacity view might do the trick, or of course one could make their own image carousel from scratch. |
Hi @irajwani I just look your code
I just add alert to check if touchableOpacity is working onPress and its working as you can see
If you want to snap to the next item just
@irajwani I hope this will help you thanks |
Anyone found a solution to this? Facing this issue as well, seems like something is blocking the touch. My button is nested inside the item |
My button is nested inside the item (in a parent |
I have several touchable elements inside my card & found that adding
to their parent views allowed touch events to arrive. Before that, |
@LordParsley Thanks for sharing! Looks like a potential solution to fix both this issue and #262. Do you mind sharing a bit of code so that we can understand your exact setup? Also, was this tested on both Android and iOS? |
@LordParsley the |
It's not working for me, only on Android |
Did anyone found the solution? I am facing the same issue. I can't click the carousel image. |
For now, I am doing something like - import Carousel, { Pagination } from 'react-native-snap-carousel'
import { State, TapGestureHandler } from 'react-native-gesture-handler'
<TapGestureHandler
onHandlerStateChange={(event) => {
if (event.nativeEvent.state === State.ACTIVE) {
openPostView() // Tap/Press action
}
}}
>
<View style={styles.slideContainer}>
<Carousel
data={PostMedia}
renderItem={renderSlide}
onSnapToItem={(index) => setActiveSlide(index)}
sliderWidth={keys.screenWidth - 60}
itemWidth={keys.screenWidth - 60}
/>
<Pagination
dotsLength={PostMedia.length}
activeDotIndex={activeSlide}
containerStyle={styles.dotsContainer}
dotStyle={styles.slideDot}
inactiveDotStyle={styles.inActiveSlideDot}
inactiveDotOpacity={0.4}
inactiveDotScale={0.6}
/>
</View>
</TapGestureHandler> |
Is this a bug report, a feature request, or a question?
A feature request / question
Hi archriss,
You've probably dealt with this already: Given that we can wrap the carousel in a TouchableOpacity like so:
`<TouchableOpacity onPress={this.props.onPress} style={{width: "100%", backgroundColor: "#fff"}}>
<Carousel
the attached onPress method will not execute when I tap the carousel. As expected, children of the opacity and the edges around the carousel if you give margin/padding, will execute onPress method and do our required function. In my case, If the user taps an image in a carousel, the app fires up a full screen modal to show full screen images, so I would really like person to be able to tap on Carousel and execute the onPress method:
() => this.setState({showFullScreenPictures: true})
If you need screenshots, please let me know. I didn't provide them as my UI is proprietary and before I make an example app for this, I just wanted to know if this question makes sense. Hope that made sense. Imad
The text was updated successfully, but these errors were encountered: