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

Stop loading all images in hidden div #31

Open
mikej2017 opened this issue Oct 23, 2016 · 1 comment
Open

Stop loading all images in hidden div #31

mikej2017 opened this issue Oct 23, 2016 · 1 comment

Comments

@mikej2017
Copy link

If I have two divs, one for view1 and another for view2 with "ng-show" and "ng-click" to toggle betwen them, if I set lazy-img tag on both, it will load all of the images from the second invisible div. If it entirely comment out that div it will only load the first 12 images as it should correctly. I checked the source of the hidden div (view2) and all of the img tags had the "src" attribute appended.

Is there anyway around this?

@jackpilowsky
Copy link

I ran into the same issue. The way I solved it was by changing the isElementInView() to

function isElementInView(elem, offset, winDimensions) { var rect = elem.getBoundingClientRect(); var bottomline = winDimensions.height + offset; return elem.offsetParent && ( rect.left >= 0 && rect.right <= winDimensions.width + offset && ( rect.top >= 0 && rect.top <= bottomline || rect.bottom <= bottomline && rect.bottom >= 0 - offset ) ); }

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