ui-pager icon indicating copy to clipboard operation
ui-pager copied to clipboard

Android pager content has different loading behaviour than iOS

Open CatchABus opened this issue 2 years ago • 3 comments
trafficstars

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 avatar Feb 08 '23 11:02 CatchABus

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

farfromrefug avatar Feb 08 '23 16:02 farfromrefug

@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 avatar Jan 29 '24 13:01 CatchABus

@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

farfromrefug avatar Jan 29 '24 18:01 farfromrefug