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.

snapToItem(0, (animated = false)) snaps to SECOND item.

See original GitHub issue

Cant snap to first item. this._carousel.snapToItem(0, (animated = true)); snaps to second one. And this._carousel.snapToItem(1, (animated = true)); snaps to third one.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
rendomnetcommented, Oct 28, 2017

@bd-arc

<Carousel
            ref={c => {
              this._carousel = c;
            }}
            loop={true}
            apparitionDelay={500}
            data={this.state.markers}
            renderItem={this._renderCarouselItem}
            sliderWidth={DEVICE_WIDTH}
            firstItem={0}
            itemWidth={CARD_WIDTH}
            inactiveSlideOpacity={0.8}
            autoplay={false}
            inactiveSlideScale={0.9}
            enableMomentum={true}
            onSnapToItem={index => this.carouselSnap(index)}
            activeSlideAlignment="center"
            autoplayDelay={0}
            containerCustomStyle={styles.cardContainer}
            contentContainerCustomStyle={{}}
          />
  carouselSnap(index) {
    const { coordinate } = this.state.markers[index];
    this.map.animateToRegion(
      {
        ...coordinate,
        latitudeDelta: this.state.region.latitudeDelta,
        longitudeDelta: this.state.region.longitudeDelta
      },
      350
    );
  }

 markerClick(index) {
     this._carousel.snapToItem(index, true);
  }
0reactions
sultan-arshicommented, Sep 17, 2019

for me (animated = true) worked but when I used (animated = false) it returns to previous image I don’t know why I think this bug still present in the library

Read more comments on GitHub >

github_iconTop Results From Across the Web

snapToItem(0, (animated = false)) snaps to SECOND item. #199
Cant snap to first item. this._carousel.snapToItem(0, (animated = true)); snaps to second one. And this._carousel.snapToItem(1, (animated ...
Read more >
React native - how to set this state with hooks instead of 'this ...
Am new to the logic of hooks and need some clarity. Im using this library https://github.com/archriss/react-native-snap-carousel and setting up ...
Read more >
react-native-snap-carousel/CHANGELOG.md - UNPKG
This allows implementing custom animations and layouts (see [the dedicated ... 30, * Fix `snapToItem` call that results in snapping to the wrong...
Read more >
Building a Smooth Image Carousel with FlatList in React Native
Carousels consolidate items within a single horizontally rotating widget. Users can scroll through items by dragging across right or left to ...
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 >

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