react-native-swiper-flatlist
react-native-swiper-flatlist copied to clipboard
onChangeIndex not triggered on web
It doesn't look like onChangeIndex is getting triggered in the browser. This was tested in Firefox and Chrome. Here's some sample code that should break:
const onChangeIndex = () => {
console.log("This is never called in the browser");
}
<SwiperFlatList onChangeIndex={onChangeIndex} />
I think I have the same issue... any workaround ?
same issue
This worked for me but you need to know each Item width and all items must be in same size
<SwiperFlatList
style={style}
onScroll={handleScroll}
renderItem={({ item, index }) => (
<TouchableOpacity style={{width:SIZES.cardImageWidth}} onPress={() => onImageClick(index)}> </TouchableOpacity >
/>
const handleScroll = (event) => {
const contentOffsetX = event.nativeEvent.contentOffset.x
const width = SIZES.cardImageWidth
const index = Math.round(contentOffsetX / width)
setPage(index)
}