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 load not working for hidden tabs #22

Closed
kevalbhatt opened this issue Feb 23, 2018 · 1 comment
Closed

lazy load not working for hidden tabs #22

kevalbhatt opened this issue Feb 23, 2018 · 1 comment

Comments

@kevalbhatt
Copy link

I have 3 tabs. and the second tab has list of cards, now when I click on the second tab then I am not able to see a card with images unless I scroll.

I debug code and found that viewport plugin is giving me trouble.

I saw one method in your document.

import { checkElementsInViewport } from 'react-lazy'

// now you're being a very lazy dev...
setInterval(checkElementsInViewport, 250)

But I don't know how it works.

Do I need to call checkElementsInViewport when I click on 2 tab?

@Merri
Copy link
Owner

Merri commented May 26, 2018

Yes, you have to manually call checkElementsInViewport() when opening a tab. Alternatively the setInterval trick works, but it will cause continuous extra CPU consumption.

This complexity is the downfall of giving control of the performance impact of lazy loading: I didn't want to make a solution where there is a hidden performance impact.

I'm planning on making a v1 release that uses IntersectionObserver, which in turn won't require having checkElementsInViewport as it handles this issue better.

@Merri Merri closed this as completed May 26, 2018
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