Reputation: 12641
When doing lazy loading (table of UICollectionView),
for a correct result, you should NOT begin downloads, when the user is scrolling very quickly over the collection.
So, imagine a vertical scroll with 200 panels each with an image; four or five are seen onscreen at a time.
When it first loads, the first 4 visible images should begin loading. If you scroll down a little, the newly visible images should begin to load.
BUT if the user: very quickly scrolls down to (say) position 100 and then positions the view showing items 100-104 ... you ideally SHOULD NOT starting loading the images which the user "skimmed" over very quickly (say, 4 through 99), you should only kick in the downloads when the user stops scrolling very quickly, and apparently is stopping or slowing on some images.
So, this is a standard thing you have to do in any high-quality lazy-loading scroll. You don't start loading when the user is skimming.
My question is simply: does SDWebImage support this concept? If not is there another popular ready-made approach? Cheers
Upvotes: 2
Views: 525
Reputation: 119242
It doesn't support it, because it's usually a category on an image view, but it would be pretty straightforward to add the ability yourself.
Assuming you were kicking off the image load in cellForItem...
, you'd add a dispatch after block which would only kick off the load if the same cell still had the same index path after, say, 0.2 seconds.
I'd check if you had a measurable problem before doing anything, though - AFAIK SDWebImage (and definitely the AFNetworking image view category) will cancel any outstanding URL requests when a new one is received, so you might be making an unnecessary optimisation.
Upvotes: 5