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

This + responsive images #1

Open
Culpable opened this issue Apr 21, 2018 · 3 comments
Open

This + responsive images #1

Culpable opened this issue Apr 21, 2018 · 3 comments

Comments

@Culpable
Copy link

Culpable commented Apr 21, 2018

Hiya,

Is there any way to get this to play nicely with responsive images?

Specifying my width and height in my HTML, I am unable to add:
height: auto;

Without breaking the script.

(Note I'm having to specify !important to avoid it being overridden)

There might be a CSS solution to this, but I can't think of one.

Maybe once the script is loaded, it then adds a custom CSS class with
height: auto !important; ?

Just split balling here. Not sure if that would work.

@RevillWeb
Copy link
Owner

Hey Culpable, thanks for taking the time to create an issue. Currently, a static width and height are required to calculate whether the images will be in the viewport or not. I don't currently know of a performant way to avoid this :(

@AleksandarAleksandrov
Copy link

Maybe display a 1px X 1px div, to detect if it is visible, so that way he can load height: auto images. Just a sugestion, react-loadable-visibility I think does it that way.

@RevillWeb
Copy link
Owner

I'll take a look at that library thank you.

I don't think this will work in at least a few cases though. Let's say you have quite a few images on the screen, like in the demo for this repo. Let's say that each image is actually 300px x 300px which meant that 5 images would initially be visible in the user's viewport. So we want to display these immediately and pre-cache/lazy-load any other images on the page. If the library didn't know that the images are actually 300px x 300px and thought they were 1px x 1px as suggested then it's probably just going to immediately download and render them all, instead of pre-caching and lazy-loading because it thinks they are all in the user's current viewport :(

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