Giter Site home page Giter Site logo

Comments (4)

USPTraining avatar USPTraining commented on May 22, 2024 2

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.

sgruhier avatar sgruhier commented on May 22, 2024

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.

MakG10 avatar MakG10 commented on May 22, 2024

Here are approaches I took to preserve correct items order when there are images with various heights involved:

  1. Set horizontalOrder: true in [options]
  2. 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.

wynfred avatar wynfred commented on May 22, 2024

To keep the order of images, you could

  1. load images synchronously
  2. call reload_items and layout to refresh the order after all images are loaded #18 (comment)
  3. if you know the dimension of image before it's loaded, add a div as placeholder

from ngx-masonry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.