onSnapToItem wrong Index (RTL mode, Android)
when using RTL or inverted , what happen is , it invertes the indices as well, so if the data array is [0,1,2,3,4] becomes [4,3,2,1,0] , which is wrong , because despite the fact the carousel showing the layout in LTR or RTL fashion, the index should be the same!
also trying to disable inversion using inverted={false} not working, any suggestions here?
EDIT: only happens on Android
Is it working properly if you change this line to return false;?
@bd-arc nope , unfortunately it didn't fix the issue!
try setting inverted to true in rtl
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
this line in function _needsRTLAdaptations in Carousel.tsx or Carousel.js in snap_carousel src folder is causing error: error line: return IS_RTL && IS_ANDROID && !vertical;
convert the line into => return IS_RTL && IS_ANDROID && !vertical;
so the function should now look like this _needsRTLAdaptations () { const { vertical } = this.props; return IS_RTL && !IS_ANDROID && !vertical; }
it has fixed the issue in case of rtl on my end
make sure you do this as well: onSnapItem(index => setActiveSlide(isRtl ? data.length - 1 -index : index))