Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onChangeIndex not triggered on web #186

Open
crcn opened this issue May 16, 2024 · 3 comments
Open

onChangeIndex not triggered on web #186

crcn opened this issue May 16, 2024 · 3 comments

Comments

@crcn
Copy link

crcn commented May 16, 2024

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}  />
@LouisSyfer
Copy link

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

@Qurat-ul-ainn
Copy link

same issue

@Ahmed712441
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants