Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove placeholder only when image fully loaded? #116

Open
maglev99 opened this issue Nov 24, 2022 · 2 comments
Open

How to remove placeholder only when image fully loaded? #116

maglev99 opened this issue Nov 24, 2022 · 2 comments

Comments

@maglev99
Copy link

Hi, is there a way to only remove the placeholder after the image is fully loaded/afterLoad() event is fired?

For slower loading images the placeholder will disappear but the image container will still be blank for several seconds before it slowly fills with the loaded image from top to bottom. It would be great to not show the image and display the placeholder until the image has completely loaded. Thank you!

@SaiRO97
Copy link

SaiRO97 commented Nov 28, 2022

In my experience, this behavior happens when you use the placeholder prop instead of placeholderSrc. The image will also fill slowly, but the placeholder must wait until it is completely filled. If you want to haven't a fill, try playing with the effects of blurs and opacity. Hope it will help

@maglev99
Copy link
Author

maglev99 commented Nov 28, 2022

@SaiRO97 Thanks for the advice! What I ended up doing was set the width and height of the LazyLoadImage to 0 so that it still loads as expected when scrolled to on the viewport, and display the placeholder by default. When the image is fully loaded call afterLoad() to set the size of LazyLoadImage back to normal and make the placeholder hidden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants