Comments (4)
I am also facing the same issue. if I don't use [useImageLoaded] then they are appearing in the right order but not stacked properly
from ngx-masonry.
The way it's implemented, it cannot work. It removes DOM element, then load images, then add DOM element back when images are loaded. Nothing ensure that async load images will keep DOM element order. There is also another bug/side effect. mansory.layout() is called multiple times.
So far, from what I understood about ngx-mansory, it's hard to fix. I'll try something first in my project and see it I can contribute to ngx-mansory. In any case, I'll share what I come up with.
from ngx-masonry.
Here are approaches I took to preserve correct items order when there are images with various heights involved:
- Set
horizontalOrder: true
in[options]
- Update masonry layout when image gets loaded:
<ngx-masonry [options]="masonryOptions" [updateLayout]="updateMasonryLayout">
<ngxMasonryItem *ngFor="let trip of tripsData">
<img src="image.jpg" (load)="updateMasonryLayout = !updateMasonryLayout">
</ngxMasonryItem>
</ngx-masonry>
Layout is updated every time the variable updateMasonryLayout
is changed. If you have a lot of items you may wanna do this every n-th element for performance reasons.
from ngx-masonry.
To keep the order of images, you could
- load images synchronously
- call reload_items and layout to refresh the order after all images are loaded #18 (comment)
- if you know the dimension of image before it's loaded, add a div as placeholder
from ngx-masonry.
Related Issues (20)
- masonry is break when is on chrome print pdf pre-viewer
- fitWidth broke the resize behavior
- Window is not defined issue after updating to angular v16 HOT 4
- not import in standalone component HOT 1
- SSR: ngOnDestroy generate "Cannot read property 'remove' of undefined" HOT 1
- fitWidth breaks resize HOT 7
- Unable to resolve dependency tree (i'm using Angular 11.x) HOT 1
- Centering items inside the ngx-masonry
- Dynamic responsiveness HOT 2
- Dynamic loading of masonryItems HOT 3
- Angular 13 Support HOT 6
- Could you provide the "live example" repo in README? HOT 1
- 'ngx-masonry' is not a known element HOT 1
- Change array order breaks masonry template 🤔 HOT 5
- How to set containerStyle? HOT 4
- support for angular 14 HOT 4
- Support for Angular 13 HOT 3
- Angular 14 - 'NgxMasonryModule' does not appear to be an NgModule class. HOT 1
- Tests failing with the message ReferenceError: require is not defined HOT 6
- Reference Error: window is not defined Angular 14 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-masonry.