-
Notifications
You must be signed in to change notification settings - Fork 430
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
(Android only) onVisibleIndexesChanged callback not always firing #103
Comments
Ok I did some digging and found that the second issue is because of decimal points here:
In my case the About the first bullet, I still don't know I'll keep on digging. |
- No longer receiving 2 onVisibleIndexesChanged callbacks - No longer accidentally skipping onVisibleIndexesChanged callbacks
Are you using non deterministic rendering? Rounding off will be a double edged sword because it might fix your use case and break others. Can you share your layout provider implementation? |
@naqvitalha The issue is clearly visible on this snack https://snack.expo.io/S1OeHVAQM (if you run it on an Android device).
Also you can check the layout provider on that link too, but here is the actual code: this.layoutProvider = new LayoutProvider(
(index) => {
const date = this.indexToDate(index);
if (date) {
const miniCalMonthMoment = momentFromDateWithoutTimezone(date);
if (miniCalMonthMoment) {
const monthKey = miniCalMonthMoment.format(TimeFormats.MINICAL_KEY_FORMAT);
if (props.miniCalData) {
const dayData = props.miniCalData.getIn([monthKey, 'data']);
if (dayData) {
const weekCnt = Math.ceil(dayData.size / 7);
if (weekCnt >= 6) {
this.minicalHeight = props.h * (props.showMonthTitles ? 0.42 : 0.37);
return VIEW_TYPES.LARGE_SIZE;
}
}
}
}
}
return VIEW_TYPES.NORMAL_SIZE;
},
// Providing heights and widths for given types, doing deterministic way for perf
(type, dim) => {
switch (type) {
case VIEW_TYPES.LARGE_SIZE: {
// eslint-disable-next-line
dim.height = props.h * (props.showMonthTitles ? 0.4 : 0.35);
break;
}
case VIEW_TYPES.NORMAL_SIZE:
default: {
// eslint-disable-next-line
dim.height = props.h * (props.showMonthTitles ? 0.48 : 0.42);
break;
}
}
// eslint-disable-next-line
dim.width = this.minicalWidth;
},
); |
I tried the expo. First visible month was January. And I don't even get the second issue. What is happening? Device specific issue? |
I'm running this on a
both Truncating the number after the decimal point fixes both issues for us. What side issues do you think that might create btw? |
Check slack once. I've posted a video of my experience |
Truncating is a problem in non deterministic rendering where item widths and heights can be very irregular. It would be very hard to figure out if that rounding off will lead to right or wrong. E.g in our search page a lot of time our rendered item heights are like 120.56003... Assuming anything is very hard there |
I'm not in front of slack atm, I'll join you in ~40 mins. |
Any update? |
Not really, I still get that issue. It's a real pain, and I'm using hacks to determine what's visible, and that doesn't always return the right index. |
Closing due to inactivity. |
Hey there I have no idea what causes this but even in 1.2.6:
I debugged a little bit and found that the reason is that when that recycler calculates the visible indices, the old visible indices array is the same with the new indices array, so nothing gets dispatched.
recyclerlistview
is first mounted, I receive 2onVisibleIndexesChanged
events. The first one is right (now only contains 1 item), and the second one is wrong (contains 2 items).Ever seen that?
By the way both of those issues only happen on Android (I think).
The text was updated successfully, but these errors were encountered: