Does SDWebImage support “not-when-fast-scrolling” (skimming) for lazy loading?

萝らか妹 提交于 2019-12-24 04:42:08

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/25347854/does-sdwebimage-support-not-when-fast-scrolling-skimming-for-lazy-loading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!