zvonicek / ImageSlideshow

Swift image slideshow with circular scrolling, timer and full screen viewer
MIT License
1.77k stars 475 forks source link

ActivityIndicator & image preload only triggered when scrolling to the image ends #267

Open ashleyhenderson opened 6 years ago

ashleyhenderson commented 6 years ago

When scrolling through a slideshow, image preload is only triggered when the slideshow scrollview has finished scrolling. To replicate:

Ideally, this should perform more like a collectionview's cellforitemat, where the preloading is triggered when the adjacent image is called by the slideshow (before the image appears on-screen). This issue would likely be fixed by basing preloading on the slideshow's willBeginDragging (or something similar), thus triggering the activity indicator & preload before the next image appears.

raeesmadathil commented 6 years ago

Hi, I am also facing the same issues, I got this issue only after updating to the latest version, before it was working fine (before some versions), please help me if any one have any solution.

zvonicek commented 6 years ago

Hi! Thanks for the detailed issue report. I agree, it's reasonable to trigger the image load earlier than when scrolling has finished. For activity indicator it's really a must.

I attempted to address this problem in 311a45e, branch image-preload-improvement. Could you please give it a try? It triggers the load even during the scrolling, when primaryVisiblePage changes, thus the majority of screen content is covered by a new page. I think already this is an improvement, I can, however, imagine the load being triggered even sooner, when a new page appears. But this would require slightly bigger changes.

ashleyhenderson commented 6 years ago

Thanks for getting back to me so soon, I've tried the fix (with a preload setting of 0 again) but the ActivityIndicator still has a noticeable delay before appearing in some cases when downloading images. Kingfisher's in-built activity indicator without the slideshow displays instantly. The slideshow indicator also only appears when images aren't cached in Kingfisher and have to be downloaded? Maybe this is the intended effect?

I can see that the image load is triggered halfway between each image. With a preload setting of 0, this causes the images to flicker in and out abruptly when quickly dragging over the halfway mark and back between two images. With a realistic preload setting (of 4) however, the preload works much better than before and looks to be fixed