'infinite loop is not working using loop={true} , enableSnap ={true} list is not scrolling infinte mode in android using react-native-snap-carousel
Actual Behavior
i m displaying the list in card and the card is not scrolling in the infinite mode it get strucked in middle in android
Expected Behavior
Card should be scroll in the infinite mode while scrolling in android
<Carousel
ref={c => {
this._carousel = c;
}}
carouselRef={this.props._slider1Ref}
data={this.props.data}
renderItem={this._renderItem}
sliderWidth={this.props.sliderWidth}
itemWidth={this.props.itemWidth}
loop={true}
loopClonesPerSide={this.props.loopClonesPerSide}
firstItem={this.props.firstItem}
onSnapToItem={index => this.onSnap(index)}
layout={this.props.layout}
layoutCardOffset={this.props.layoutCardOffset}
showSpinner={this.props.showSpinner}
activeSlideAlignment="start"
useScrollView={false}
activeSlideOffset={this.props.activeSlideOffset}
lockScrollWhileSnapping={true}
enableSnap={true}
enableMomentum={false}
activeSlideOffset={this.props.activeSlideOffset}
decelerationRate="fast"
// removeClippedSubviews={true}
removeClippedSubviews={false}
/>
Solution 1:[1]
Go to node_modules/react-native-snap-carousel/src/carousel/Carousel.js and edit line 820
if (nextActiveItem === this._itemToSnapTo && scrollOffset === this._scrollOffsetRef) {
this._repositionScroll(nextActiveItem);
}
to
if (nextActiveItem === this._itemToSnapTo && Math.trunc(scrollOffset) === Math.trunc(this._scrollOffsetRef)) {
this._repositionScroll(nextActiveItem);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |
