meliorence / react-native-snap-carousel

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.
BSD 3-Clause "New" or "Revised" License
10.24k stars 2.26k forks source link

When swiping item, they stop in the middle #850

Open trilam1409 opened 2 years ago

trilam1409 commented 2 years ago

Hello everyone,

There are some issues on some Android devices. Slider can't move full next one.

Screen Shot 2021-07-22 at 14 41 43

This is my code:

const carouselRef = useRef<Carousel<{uri: string}>>(null);
  const SLIDER_WIDTH = Dimensions.get('window').width;

  const [index, setIndex] = React.useState(0);

  const _goToGallery = () => {
    navigation.navigate('PropertyDetailGallery');
  };

  const _renderItem = ({item}: {item: string}) => (
    <Pressable style={PropertyDetailStyles.carouselCard} onPress={_goToGallery}>
      <ImageIndicator source={item} style={PropertyDetailStyles.image} />
    </Pressable>
  );

  const _onSnapToItem = (index: number) => setIndex(index);

  return (
    <>
      <ButtonArrow
        onPress={goBack}
        containerStyle={PropertyDetailStyles.backButton}
      />
      <Carousel
        removeClippedSubviews
        /* @ts-ignore */
        ref={carouselRef}
        data={imageList}
        renderItem={_renderItem}
        sliderWidth={SLIDER_WIDTH}
        itemWidth={SLIDER_WIDTH}
        onSnapToItem={_onSnapToItem}
      />
      <Pagination
        dotsLength={imageList.length}
        activeDotIndex={index}
        containerStyle={PropertyDetailStyles.carouselPagination}
        dotContainerStyle={PropertyDetailStyles.carouselDotContainer}
        dotStyle={PropertyDetailStyles.carouselDot}
        dotColor={BLACK_COLOR}
        inactiveDotColor={FIFTH_GREY}
        inactiveDotScale={1}
        tappableDots={true}
        /* @ts-ignore */
        carouselRef={carouselRef}
      />
    </>
  );

Do you meet this issue? Is there any way to resolve it? Thank you.

wangzeshen commented 2 years ago

4.0.0-beta6

AndreBovolini commented 2 years ago

Upgrading to '4.0.0-beta6' worked perfectly for me!

geovrisco commented 2 years ago

@wangzeshen @AndreBovolini how to upgrade? mine still on "react-native-snap-carousel": "^3.9.1",

AndreBovolini commented 2 years ago

@geovrisco you can choose the version you want like that:

yarn add react-native-snap-carousel@4.0.0-beta6

fengjueji commented 2 years ago

@geovrisco you can choose the version you want like that:

yarn add react-native-snap-carousel@4.0.0-beta6

Hi,I have the same issues, but I can't find react-native-snap-carousel@4.0.0-beta6 in npm or yarn

geovrisco commented 2 years ago

npm i react-native-snap-carousel@4.0.0-beta6

you can just install it like that

geovrisco commented 2 years ago

@AndreBovolini thanks btw,

AggravatedAstronomer commented 2 years ago

For anyone struggling with this, there is a . before the beta number. Without this, the install command will fail @fengjueji @geovrisco

npm i react-native-snap-carousel@4.0.0-beta.6

You can find this out for yourself by doing:

npm view react-native-snap-carousel and checking the dist-tags at the bottom.

ringcoa commented 2 years ago

Funny enough npm i didn't work. I used npm install and it worked.

Navipro70 commented 2 years ago

enableMomentum fix this issue (RNSC 3.6v.)

hamzasajid1995 commented 2 years ago

In react-native-snap-carousel@4.0.0-beta.6 "enableMomentum" prop is removed. so if you want to stop momentum you have to use disableIntervalMomentum: true Read More

princefishthrower commented 2 years ago

@hamzasajid1995 - do we set disableIntervalMomentum as a prop right on the component? It doesn't appear in the typings...

jbolter commented 2 years ago

4.0.0-beta.6 fixed the issue for me.

dohooo commented 2 years ago

@trilam1409 Sorry, please allow me to advertise for my open source library! ~ I think this library react-native-reanimated-carousel will solve your problem. It is a high performance and very simple component, complete with React-Native reanimated 2

MrJYJ commented 2 years ago

@hamzasajid1995 - do we set disableIntervalMomentum as a prop right on the component? It doesn't appear in the typings...

试试: yarn add react-native-snap-carousel@4.0.0-beta6

jordan2816 commented 2 years ago

Anyone know what changes make it correct?

NensiKasundra commented 2 years ago

Any Solution for the above issue?

ganesh-oracle commented 6 months ago

Upgrading to '4.0.0-beta6' worked perfectly for me!

Works perfectly