meliorence / meliorence/react-native-snap-carousel

Upon tap, Carousel does not execute onPress method for custom parent TouchableOpacity.

Open
#476 16 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

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

      ref={ (c) => { this._carousel = c; } }
      data={this.props.data}
      renderItem={this._renderItem.bind(this)}
      onSnapToItem={this.handleSnapToItem.bind(this)}
      sliderWidth={300}
      itemWidth={256}
      layout={'default'}
      firstItem={0}
      
    />
    <Text>If you touch this text, the onPress event willl fire but it does not fire when one taps the Carousel above</Text>
    {/* { this.pagination } */}
  </TouchableOpacity>`

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the TouchableOpacity wrapper and tapping the Carousel, then trace how the carousel handles touch events. Confirm the expected behavior on the reported example: tapping the carousel should trigger the parent onPress callback, including the full-screen image action.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.