react-native-swiper-flatlist icon indicating copy to clipboard operation
react-native-swiper-flatlist copied to clipboard

onChangeIndex not triggered on web

Open crcn opened this issue 1 year ago • 3 comments

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}  />

crcn avatar May 16 '24 19:05 crcn

I think I have the same issue... any workaround ?

LouisSyfer avatar May 30 '24 00:05 LouisSyfer

same issue

Qurat-ul-ainn avatar Jun 14 '24 10:06 Qurat-ul-ainn

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)
   }

Ahmed712441 avatar Jul 03 '24 22:07 Ahmed712441