Skip to content

All images are loaded at once #81

Open
@hamza-jutt

Description

@hamza-jutt

Bug description
All images are loaded at once. I did read this readme section and added placeholder but it does not work. Adding height and width works but for my case that is not suitable. On adding a placeholder the browser does show that later images in the list are not in the viewport but as soon as first image starts loading all of the images get loaded.

I think that likely reason is that when image starts loading the placeholder is replaced with image source. Now while the browser is downloading the image dimensions become 0,0 for the image as it is not loaded yet. and more image get into the viewport and they start loading and so on and so on. So adding placeholder does not work.

To Reproduce
Paste the code that is producing the issue

.placeholder {
    display: block;
    width: 167px;
    height: 252px;
}

<LazyLoadImage src={URL}
     placeholder={<span className="placeholder"/>}
     height={252}/>

List any other actions needed to reproduce the issue:
If the cache is pre filled then browser does not take time to load the image and this issue can not be seen. So disable cache and maybe emulate slow network using slow 3g in network tab.

Expected behavior
Placeholder should be there until image is loaded. Placeholder is removed as soon as the image hits viewport.

Technical details:

  • Package version [e.g. 1.5.0]
  • Server Side Rendering? [No]
  • Device [Desktop]
  • Operating System [Mac OS]
  • Browser [Chrome]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions