-
Notifications
You must be signed in to change notification settings - Fork 95
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() doesn't always fire when using swipe feature #110
Comments
I have found a work-around by also implementing |
Done a bit of digging into From a quick look, it seems like
I just had a quick look, I will try do some more investigation when I have some free time. |
@curtismenmuir thanks for reporting the issue and the work-around, if you could take a deep look at it, it would be great 🙌 |
1 similar comment
@curtismenmuir thanks for reporting the issue and the work-around, if you could take a deep look at it, it would be great 🙌 |
I also faced this issue. I noticed onViewableItemsChanged={(params) => console.log('index', params.changed?.[0]?.index)} |
Same issue persist for me also. I have noticed that onchange index trigger after some delay. Any luck ? |
I'm facing the same delay issue... :( |
+1 experiencing this issue! |
+1 having the same issue when swipe manually. |
figured out onMomentumScrollEnd solves the problem for now. Thanks @curtismenmuir Instead this, |
|
+1 having issues where onChangeIndex doesn't update the index. |
@ShobanaBohs100 onMomentumScrollEnd={({ index }: any) => setListIndex(index)} Thanks!!! this perfectly worked for IOS. but android still having same issue. What did you use for android? |
+1 |
I did a few improvements (removing re-renders and adding support for |
@gusgard Still the same issue on 3.2.2 :( |
I wasn't able to reproduce it with Expo v48, is there an example or steps you can provide me ? @bravecode |
i achieve this design and also created this code blog. |
const _onChangeIndex = React.useCallback(
({ index: _index, prevIndex: _prevIndex }: { index: number; prevIndex: number }) => {
// -> Moving it out of the condition can temporarily solve the issue. Another problem is that _onChangeIndex cannot be triggered immediately after the swipe, but needs to wait for a moment.
onChangeIndex?.({ index: _index, prevIndex: _prevIndex });
// -> First swipe right, then swipe left will not trigger _onChangeIndex.
if (_index !== _prevIndex) {
onChangeIndex?.({ index: _index, prevIndex: _prevIndex });
// onChangeIndex?.({ index: _index, prevIndex: _prevIndex });
}
},
[onChangeIndex] |
+1 I have 6 items onChnageIndex is not firing after 3rd Index.
|
If any one have any other work around for getting the index of current visible item then please let me know |
This worked for me! I was having this issue with onChangeIndex function, it would reach the third item in the array and stop counting. I'm using the list vertically and have a fixed header at the top with a height of 90px. I believe in this part of the code
the offset didn't match the height of the images in the list. I just needed to provide this information in the SwiperFlatList:
Now the onChangeIndex function is correctly returning the visible index. |
I can confirm that setting getItemLayout with correct dimensions triggers the onChangeIndex correctly, can it be added to the docs? |
hey @devakrishna33 could you kindly share your code snippet? |
same |
Should be fixed in |
by using this getting an error "Changing onViewableChanged on the fly is not supported" |
Description
onChangeIndex
callback occasionally is not fired.<SwiperFlatList>
to the bare minimum (see code example below) and issue still seen.Info
0.63.4
(also seen inv0.62.2
)react-native-swiper-flatlist
version:3.0.14
(also seen inv3.0.8
)Code Example:
Steps to recreate
The text was updated successfully, but these errors were encountered: