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

Lazy loading not working? #2057

Closed
boehsermoe opened this issue Sep 22, 2020 · 6 comments
Closed

Lazy loading not working? #2057

boehsermoe opened this issue Sep 22, 2020 · 6 comments
Assignees

Comments

@boehsermoe
Copy link
Member

What steps will reproduce the problem?

LazyLoad does not working correctly since 1.6 with IntersectionObserver. All images will be loaded at first visit.

What is the expected result?

Load only visible images

What do you get instead? (A Screenshot can help us a lot!)

All images are loaded.

Additional infos

Q A
LUYA Version 1.7
Operating system macOS
Browser Chrome, Firefox and Safari
@nadar
Copy link
Member

nadar commented Sep 22, 2020

@TheMaaarc did the lazy loading overhaul. Do you have more informations @boehsermoe which might help him?

@boehsermoe
Copy link
Member Author

Not really... I start to debug it a bit and at page load the function imageIntersects will be called and each entry check with isIntersecting is true and load the image.

if (entry.isIntersecting) {

Maybe this can help:

I found a example here where it works fine -> https://jsfiddle.net/umojfbLq/

But if I change the root node to the body node (like

root: document.getElementsByTagName('body')[0],
)

It does work correctly -> https://jsfiddle.net/umojfbLq/2/

@nadar
Copy link
Member

nadar commented Sep 22, 2020

Thanks for taking time for the investigations. I would say that's perfectly more info and i am sure @TheMaaarc will find a solution.

TheMaaarc added a commit that referenced this issue Sep 22, 2020
@TheMaaarc
Copy link
Member

The main issue seems to have been the observerOptions.root option – unset/null is the best option to use for the whole document. document & body as option had some strange behaviour.

I also added a check for the isVisible property of the newer IntersectionObserver implementation. That option tracks stuff like opacity and visibility in general but is very restrictive (opacity 0.99% results in a not visible).

@boehsermoe
Copy link
Member Author

Thank you!

@nadar
Copy link
Member

nadar commented Sep 23, 2020

i'll trigger a release today

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

No branches or pull requests

3 participants