MacOS: both iOS and Android simulator
Which versions are you using:
Valid indexes on swipe forward and back. Actual log using v1.6.0-rc.2 which doesn't have an issue:
_LOG index: 1 << yes, 1, as 0 is just dismissed
LOG index: 2
LOG index: 3 << just swiped to the last slide
LOG index: 2 << going back
LOG index: 1
LOG index: 0 << to the beginning_
onTouchStartCapture has the same issue.
_LOG index: 0 << it is an index of second view, expected "1"
LOG index: 1
LOG index: 2 << just swiped to the last slide
LOG index: 3 << I swiped back, but index is increased
LOG index: 2
LOG index: 1 << I'm on the first slide_
examples/components/Swiper/index.js with loop={false} doesn't work.
I couldn't build and run examples in forked project, too many errors (gyp, not found simulator, etc). So, I gave up fixing them and google solutions, and I just copied and pasted it to my own project.
yes,it has this problem!
We do get the correct index on expo though, On RN it's giving wrong index as described.
Swiper version : 1.5.14
RN: 0.60.5
@losikov , I found temporary solution.
const handleScrollEnd = useCallback((e, state, context) => {
setTimeout(() => {
console.log(context.state.index); // here you will get right index
});
}, []);
return (
<Swiper
onMomentumScrollEnd={handleScrollEnd}
containerStyle={styles.wrapper}
showsPagination={false}
>
{t.map((_t, index) => {
return (
<View key={index} style={styles.test}>
<Text>{_t}</Text>
</View>
);
})}
</Swiper>
)
Most helpful comment
yes,it has this problem!