Open TheHacky opened 5 years ago
+1
@TheHacky Have you found a solution?
@TheHacky Have you found a solution?
I used integers for all my values. Because I want to use a percentage for my size, I use Math.floor to break it down to integer pixel.
@TheHacky Sorry, I don't understand you very much. Is there any code for me to see?
@TheHacky Sorry, I don't understand you very much. Is there any code for me to see?
If you calculate your sizes with a percentage, e.g.
width: '50%'
or with a package like react-native-responsive-dimensions:
width: responsiveWidth(50)
then you got floating numbers. Instead, I use Math.floor to round up the value
width: Math.floor(responsiveWidth(50))
@TheHacky Sorry, I don't understand you very much. Is there any code for me to see?
If you calculate your sizes with a percentage, e.g.
width: '50%'
or with a package like react-native-responsive-dimensions:
width: responsiveWidth(50)
then you got floating numbers. Instead, I use Math.floor to round up the value
width: Math.floor(responsiveWidth(50))
This does not seem to solve the problem of sliding to the right when the loop slides, it will not loop.
This does not seem to solve the problem of sliding to the right when the loop slides, it will not loop.
I think you are right. It works than for iOS, but not for Android. Maybe, it refers to #529.
Same here! Any updates on this issue ?
@TheHacky Sorry, I don't understand you very much. Is there any code for me to see?
If you calculate your sizes with a percentage, e.g.
width: '50%'
or with a package like react-native-responsive-dimensions:
width: responsiveWidth(50)
then you got floating numbers. Instead, I use Math.floor to round up the value
width: Math.floor(responsiveWidth(50))
I solved this issue using this comment's solution - by providing integer values in sliderWidth
and itemWidth
properties in Carousel
component.
So my code is like this:
const carouselItemWidth = Math.floor(screenWidth * 0.68);
<Carousel
sliderWidth={carouselItemWidth}
itemWidth={carouselItemWidth}
{...otherProps}
/>
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
286 # Is this a bug report, a feature request, or a question?
bug report
Have you followed the required steps before opening a bug report?
(Check the step you've followed - put an
x
character between the square brackets ([]
).)Have you made sure that it wasn't a React Native bug?
I can't find anything about this issue.
Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?
iOS 12.2 Android Simulator on Snack
Is the bug reproductible in a production environment (not a debug one)?
Yes.
Environment
Environment: React: 16.5.0 React native: 0.57 (Expo SDK 32.0.0) react-native-snap-carousel: 3.8.0
Target Platform: Android (5.0) iOS (9.2)
Expected Behavior
The slides looping on both sides endlessly.
Actual Behavior
The slides loop only once (regarding loopClonesPerSide) on the right side (swiping to left). On the other side, everything works as intended.
Reproducible Demo
https://snack.expo.io/@thehacky/floating-point-error-in-carousel
Steps to Reproduce