question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tapping/Clicking last item causes carousel to snap back to second last item

See original GitHub issue

I have TouchableOpacity child Items within the Carousel component - where the onPress on the TouchableOpacity items work fine.

However, when tapping/clicking on the last item, it will cause the carousel to snap back to the second last item.

Has anyone else experienced the same issue?

// Example
render() {
  const slides = this.props.items.map((entry, index) => {
    return (
      <TouchableOpacity
        onPress={() => { this.props.onPress() }}
        key={`entry-${index}`}
        >
          <View>
            <Image
              style={styles.imageContainer}
              source={entry.illustration}
              />
          </View>
        </TouchableOpacity>
      );
  });

  return(
    <Carousel
      {...this.props}
      ref={(carousel) => { this._carousel = carousel; }}
      showsHorizontalScrollIndicator={false}
      snapOnAndroid={true}
      removeClippedSubviews={false}
      sliderWidth={sliderWidth}
      itemWidth={itemWidth}
      slideStyle = {0}
      onSnapToItem = {(index) => { this.props.onSnapToItem() }}
      >
       { slides }
    </Carousel>
  )
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
bd-arccommented, Apr 4, 2017

Ok, seems like a top priority 😃 I’ll try to reproduce and fix it shortly.

2reactions
bd-arccommented, Apr 5, 2017

@XavierColombel I know since I’d like to use it myself 😉 We’re still working on it but it’s really complicated and we didn’t have enough time to tackle it recently. Stay tuned though!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Input inside Carousel Item causes jump back to ... - GitHub
Carousel should move to the next item smoothly. Actual Behavior. Often, the carousel snaps back to the previous item and the <TextInput> gains ......
Read more >
React Native Snap Carousel - First Item - Stack Overflow
Currently when the carousel loads it loads the first index instead of the one I tell it to with FirstItem. When I refresh...
Read more >
react-native-snap-carousel - npm
Swiper/carousel component for React Native with previews, multiple layouts, parallax images, performant handling of huge numbers of items, ...
Read more >
react-native-snap-carousel/CHANGELOG.md - UNPKG
147, * Fix issue with padding on iOS that could cause the carousel to snap back when its last item was clicked. 148....
Read more >
React Native carousel with react-native-snap-carousel
Editor's note: This article was last updated 27 April 2022 to reflect ... reasons; onSnapToItem : Snaps to a carousel item programmatically ...
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