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

Force loading image even when not visible #110

Closed
idoshamun opened this issue Oct 11, 2016 · 11 comments
Closed

Force loading image even when not visible #110

idoshamun opened this issue Oct 11, 2016 · 11 comments

Comments

@idoshamun
Copy link

I want some images on my website to lazy load without even being inside the viewport.
In simple words, I want to skip elementInView check and force loading the image.

@dinbror
Copy link
Owner

dinbror commented Oct 11, 2016

Hi @idoshamun.
What about the public function, load(), that comes with blazy?

@idoshamun
Copy link
Author

It is actually much easier to just pass an option instead of calling the load function and passing the right elements, in my opinion anyway

@dinbror
Copy link
Owner

dinbror commented Oct 11, 2016

Yes :) but how would it know which images to load or not to load outside the viewport. Will you add a specific class or are you looking after a feature like gajus is proposing?

#104

@idoshamun
Copy link
Author

#104 could help in other use cases.
I guess what I am aiming for is an option to pass to blazy constructor and every element in the given selector will be load without any relation to the viewport

@dinbror
Copy link
Owner

dinbror commented Oct 12, 2016

I see. But you can do that quite easy with the load function. I want to keep the script as small as possible:

var imagesToLoad = document.querySelectorAll('.force-lazy-load');
var blazy = new Blazy();
blazy.load(imagesToLoad);

@idoshamun
Copy link
Author

I'll check this out!

On Wed, Oct 12, 2016, 19:50 dinbror [email protected] wrote:

I see. But you can do that quite easy with the load function. I want to
keep the script as small as possible:

var imagesToLoad = document.querySelectorAll('.force-lazy-load');
var blazy = new Blazy();
blazy.load(imagesToLoad);


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#110 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AB5qHV7UC9DTeLf7m_JevmQf9Jb4J63sks5qzQ_wgaJpZM4KTSmi
.

@k03n00b
Copy link

k03n00b commented Oct 14, 2016

I think there could be better ways than ele.offsetWidth to check if element is visible or not.
At least (ele.offsetWidth > 0 && ele.offsetHeight > 0) should be changed to (ele.offsetWidth > 0 || ele.offsetHeight > 0), because then it works with visible elements where's only height.

Used multiple hours to solve why my cover image wasn't loaded and loadInvisible did the trick.
I have regular div with CSS background-image for preloading and few floating elements inside it, so offsetWidth is zero, even element is visible and real width for this element is over 600px.

@dinbror
Copy link
Owner

dinbror commented Oct 20, 2016

Hey @k03n00b

Do you have a link. I would like to see what you have done :)
I always reserve the space for an image or background to avoid page reflows when it lazy loads

@dinbror
Copy link
Owner

dinbror commented Oct 23, 2016

Hey @idoshamun

Can I close this one?

@idoshamun
Copy link
Author

Yap, if anything new pops up I'll let you know

On Sun, Oct 23, 2016, 21:25 dinbror [email protected] wrote:

Hey @idoshamun https://github.com/idoshamun

Can I close this one?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#110 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AB5qHeB2ur_WthMoCrE2RhSpfWdM2ynhks5q26aOgaJpZM4KTSmi
.

@dinbror
Copy link
Owner

dinbror commented Oct 25, 2016

Coolio

@dinbror dinbror closed this as completed Oct 25, 2016
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

3 participants