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

lazy loading causes thumbnails to "jump" when selecting image that was not yet loaded

Open flynorc opened this issue 8 years ago • 2 comments

I'm experiencing this "jump" when trying to go to image that was not preloaded. Is there any way to specify the "placeholder" image that would be preloaded and would be in place before the actual image is shown? or at least a way to show a blank space instead of the thumbnails jumping up and then back down when image is loaded.

I've tried adding height: 100% to .image-gallery-image and .image-gallery-slide but it does not seem to do the trick.

Am I missing something?

You can see the behaviour demonstrated here

i'm using the following code to create the image gallery:

<ImageGallery
    items={this.state.images}
    lazyLoad={true}
    showIndex={true}
    defaultImage={imagePath('2_1_no_image.png')}
    showPlayButton={false}
/>

and this.state.images is an array of objects with only thumbnail and original keys for each object in array.

Thank you for any information that could help debug this issue.,

flynorc avatar Jul 30 '18 15:07 flynorc

I have the same issue, did anyone find a good workaround?

Martsyalis avatar Aug 22 '18 18:08 Martsyalis

Unfortunately, because of lazyLoad the height necessary to fill the container for the gallery is unknown when you try to go to an image that is not preloaded. A workaround for this is to override/add a fixed height to one of the wrappers (assuming your gallery & images have a fixed height).

.image-gallery-slides {
    height: 500px;
}

This will keep the image height fixed. screen capture on 2018-09-01 at 21-52-40

xiaolin avatar Sep 02 '18 01:09 xiaolin