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

Reset failure counter when a valid target has been found #42

Closed
wants to merge 1 commit into from

Conversation

joseprio
Copy link

I was experiencing some problems with lazyload and my website, and I found out that lazyload works by processing the images as they're found in the document.

The "failure_limit" option was the obvious solution, but to really fix it in my particular layout it would require a large number; the page consists of 5 vertical columns with 4 images each, so I thought that by just resetting the counter, the number of images per column, it would fix the problem and be optimal when no images need to revealed.

I believe that my solution makes sense and may help other users of lazyload, so I hope you consider merging it in the main branch.

@tuupola
Copy link
Owner

tuupola commented Jul 31, 2012

Wouldn't it make more sense to bind Lazy Load separately to each of the vertical columns?

$("#column-1 img").lazyload({ ... });    
$("#column-2 img").lazyload({ ... });
$("#column-3 img").lazyload({ ... });

@joseprio
Copy link
Author

joseprio commented Aug 2, 2012

In the case of the website I developed, it definitely does make more sense to use a single selector, as it has 3 rows with 5 columns each.

15 lazyload instances would be fired with each scroll event, and I believe that at least 15 images would be checked everytime. This could make some combination of systems and browsers feel laggy. In case you're curious about the layout, the website is www.hipvids.com

I think it makes sense to reset the counter once an image has been found, since it would make sense to assume that more images may have to be revealed once an unexpected one has been found. Why stop if an arbitrary total number has been hit? In the website I mentioned, setting the failure limit to 4 makes it 100% sure that all images that have to be revealed will appear correctly. It will obviously make it check a few more images than the current solution, specially if it actually find images that need to be revealed, but the performance difference should be minimal in all scenarios I can imagine.

@tuupola
Copy link
Owner

tuupola commented Aug 3, 2012

Yeah it makes sense. Will merge to 1.8.1.

@tuupola
Copy link
Owner

tuupola commented Aug 17, 2012

Thanks! Fixed in 1.8.1. Release coming soon (tm).

@tuupola tuupola closed this Aug 17, 2012
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

Successfully merging this pull request may close these issues.

2 participants