nativescript-community/ui-pager

Android pager content has different loading behaviour than iOS

CatchABus opened this issue · 3 comments

In android, when you navigate to a page with a nested pager, its items will all render at the same time even though the rest of pager items aren't visible.
Pager has different behaviour in iOS however and loads pager items when user actually navigates to them for first time. It seems UICollectionView items are actually lazy-loaded.

I think iOS approach is the best as it doesn't stress UI on pager rendering.
@farfromrefug Do you think android fragments could solve this?

@CatchABus the issue is a cache size issue. On android you can change it with pageCount property. By default it is set to 0. Need to check what it means.
I will also in the weeks to come rename that property to cacheSize or something like it.
https://developer.android.com/reference/androidx/viewpager2/widget/ViewPager2#setOffscreenPageLimit(int)

@CatchABus the issue is a cache size issue. On android you can change it with pageCount property. By default it is set to 0. Need to check what it means. I will also in the weeks to come rename that property to cacheSize or something like it. https://developer.android.com/reference/androidx/viewpager2/widget/ViewPager2#setOffscreenPageLimit(int)

Even though default is supposed to be -1 for pagesCount and native, I see plugin sets it to 3 on initNativeView: https://github.com/nativescript-community/ui-pager/blob/master/src/ui-pager/index.android.ts#L107

@CatchABus indeed it was the default when I took over the plugin. not sure but I think 3 means one left, current and one right