react-photo-gallery icon indicating copy to clipboard operation
react-photo-gallery copied to clipboard

Add on load callback parameter

Open wmsiddiqui opened this issue 5 years ago • 3 comments

Added a callback parameter which will be called when all images in the gallery have finished loading.

This can allow the parent component of Gallery to implement things such as spinners or other mechanisms for smoother transitions when the images are taking too long to load.

wmsiddiqui avatar Oct 16 '19 03:10 wmsiddiqui

Coverage Status

Coverage increased (+0.2%) to 86.755% when pulling c7cb7420f38cc90b42206cbab34cbd08c80ca8b4 on wmsiddiqui:master into 0bb8e4c4a027c021f8a5a06de71e89026596fd95 on neptunian:master.

coveralls avatar Oct 16 '19 03:10 coveralls

I'm not quite sure how to mock out the onLoad on the img for the jest tests. I will look into this later, unless someone else has a good idea and can contribute or point me in the right direction.

This fix is very open ended, but it gives the calling component a lot of control over what can be done to make the UX a lot smoother.

wmsiddiqui avatar Oct 16 '19 03:10 wmsiddiqui

This is what it looks like as is, with images that take a while to load. GalleryWithoutCallback

With a callback, it allows the parent component to handle the loading to make it smoother. Of course, this is up to the parent component on how this is implemented, but adding this functionality enables many possibilities. GalleryWithCallback

wmsiddiqui avatar Oct 16 '19 05:10 wmsiddiqui