-
Notifications
You must be signed in to change notification settings - Fork 53
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
Using with Image lazyload or non-image tag is not rendered properly #69
Comments
Hi, thank you for submitting a PR. I'm not sure how the image loading mechanism is causing problem here. It should be pretty simple to layout if you don't have image tags. I see you have a Let me know if I misunderstood your question or if you have other questions. Thanks. |
@wynfred https://github.com/wynfred/ngx-masonry/blob/master/src/lib/ngx-masonry.directive.ts#L42 look at here, it is the whole part of ngAfterViewInit caused the issue. My pr could give an option to use image tag or any image lazyload methods. have you try this yet? https://stackblitz.com/edit/ngx-masonry-layout-issue-1zeuss?file=src%2Fapp%2Fapp.component.html
image lazyload:
Non-image Tag:
|
I found the problem here is the "ordered" mode was designed to work with items with image, so the non-image tags are not working. I'll think about how to handle non-image tags in "ordered" mode. |
Are you testing on Safari? If you test on chrome, you should be seeing empty with Chrome native I also just added
https://stackblitz.com/edit/ngx-masonry-layout-issue-1zeuss?file=src%2Fapp%2Fapp.component.html Basically below codes would detect if the image loaded completely or error then add to
If you have any feedbacks, please add to this PR. It should be ok for non-image tags even with |
Hi, thanks for the info. Now I understand this problem but I'm not sure how you expect this library to work with lazy loaded images? Basically the browser would need images to be at their exact position so it can calculate the viewport distance and then load the images. However, masonry needs the images to be downloaded first so it can calculate the positions. |
Please look at the updated readme as well: https://github.com/wynfred/ngx-masonry/pull/71/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R133 This lib basically is not supporting image lazyload. If the user needs to have lazyload, they have to skip this part The basic solution to fix the overlapping issue is pre-adding at least the height for each item. Isn't what you suggest as well for non-image tag? Also, the core lib If |
Thanks for the explanation. If you're using lazy loaded images and non-image elements, items should always be ordered. You don't need the To fix the lazy load problem, I would prefer not having a separate option. The library should be able to handle that by default. And if you prefer a library that wraps the core lib and doesn't have these modifications, you can try version 1.x |
@wynfred thanks. And you don't have any other solutions? I am pretty sure it is a very important piece right now to make a site faster. |
I have a list of different items some with images and some without. My dirty hack until we get a fix for it is: Whenever i have a post that doesn't contain any image I'l just append this: The fakeImg property is just a hardcoded 1x1px base64 type image (data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgA.....) |
@wynfred The layout is not rendered properly when using image lazyload or has no image tags.
Example:
https://stackblitz.com/edit/ngx-masonry-layout-issue-1zeuss?file=src%2Fapp%2Fapp.component.html
The text was updated successfully, but these errors were encountered: