Infinite loop is not working using loop={true} enableSnap ={true} in android
See original GitHub issueInfinite loop is not working using loop={true} , enableSnap ={true} list is not scrolling infinte mode in android
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
Code
<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}
/>
Environment
“react-native”: “0.61.1”, “react-native-snap-carousel”: “^3.8.1”
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:43 (1 by maintainers)
Top Results From Across the Web
infinite loop is not working using loop={true} , enableSnap ...
Go to node_modules/react-native-snap-carousel/src/carousel/Carousel.js and edit line 820 if (nextActiveItem === this.
Read more >How to test that a function doesn't infinite loop - Elm Discourse
I have a bunch of functions designed for navigating a 2d grid: up, down, ... to run the function to ensure it doesn't...
Read more >Loops in Java – Ultimate Guide - Funnel Garden
An infinite while loop will occur when the boolean condition is always true. This loop could still be broken out of if inside...
Read more >Android Things Infinite Loop ( DIRECTION_IN ) - B4X
All work in DIRECTION_OUT_INITIALLY_LOW, but if i add DIRECTION_IN i have an infinite loop True - False. In summary Statechanged changes ...
Read more >Infinite Loop in C - Javatpoint
Infinite Loop in C with Tutorial, C language with programming examples for beginners and professionals covering concepts, c array, c pointers, c structures, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JoaoCEAlmeida In line number ~820 in Carousel.js file, we have this code -
if (nextActiveItem === this._itemToSnapTo && scrollOffset === this._scrollOffsetRef) { this._repositionScroll(nextActiveItem); }
So scrollOffset and this._scrollOffsetRef didn’t have same numbers after the decimal. Not sure what causes this. But truncating the decimal part of it before checking equality fixed this issue for me -
Math.trunc(scrollOffset) === Math.trunc(this._scrollOffsetRef)
.Hope this helps !
Hi all, I have solved that issue in my app. sliderWidth and itemWidth must be integers.
<Carousel loop={true} data={products} renderItem={renderItem} inactiveSlideScale={1} inactiveSlideOpacity={1} sliderWidth={Math.round(deviceWidth)} itemWidth={Math.round(deviceWidth * 0.37)} />