Open Tylerian opened 6 years ago
Right now you can use layout's insetVisibleFrame(by insets: UIEdgeInsets)
and specify a negative insets to achieve the preloading effect. It is simple to use but it displays more cells.
I guess what you want is to only prefetch the data and not load the cells. Right now CollectionKit doesn't support it. but it should be easy to add.
You can probably realize this yourself. Maybe contributing as a PR. I will just give some idea about this.
We can create a subclass of BasicProvider
or add this function directly to BasicProvider
.
In visibleIndexes(visibleFrame: CGRect)
ask the layout to find visible indexes for a bigger area while keeping a list of what is displayed. then for those that are not on screen, you can call your own delegate or closure callback to prefetch the data.
Are there any plans on implementing something similar to
UICollectionViewDataSourcePrefetching
so we can preload stuff like images before the cells containing them get visible?It could be implemented as a callback that notifies us of the
IndexPath
s that are going to be presented and the ones that are going to be removed.