question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ngFor + a static element creates a gap in the grid

See original GitHub issue

First, thank you for this amazing lib! I’m having an issue with the following code snippet:

<ngx-masonry [options]="{ gutter: 15 }">
    <div ngxMasonryItem class="document masonry-item" *ngFor="let number of [0,1,2,3,4]">
        <div class="content">
            <div class="icon">
                <div class="triangle-topright"></div>
                <mat-icon>mic</mat-icon>
            </div>
        </div>
        <div class="label">Record {{number}}</div>
    </div>
    <div ngxMasonryItem class="document new masonry-item" (click)="recordReport">
        <div class="content">
            <div class="icon">
                <div class="triangle-topright"></div>
                <mat-icon>add</mat-icon>
            </div>
        </div>
        <div class="label">Upload a record</div>
    </div>
</ngx-masonry>

the combination of ngFor and a static element seems to create a gap in the grid:

image

this is not the case without the static element:

image

Is it possible to use ngx-masonry this way? Otherwise, do you know a workaround?

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
femtozercommented, Jul 12, 2020

Thanks! The ngIf solution works perfectly

Le ven. 10 juil. 2020 à 21:52, wynfred notifications@github.com a écrit :

Hello, I’m not sure what’s the root cause here but a workaround would be using ngif to display the extra item after the list are loaded. Or add the item to the array with a “type” property and then ngswitch

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wynfred/ngx-masonry/issues/50#issuecomment-656861427, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADENQOMSSGKVYARKNBRJ6WLR25WQXANCNFSM4OWPTYHQ .

0reactions
thesleortcommented, Jun 28, 2021

For me it appears that static elements are added immediately to the list of items, but then after that they are spotted as new items, which means that every static element will add a new empty gap. In my case I have 5 static elements, which means that the total count of items in the masonry is 10.

Read more comments on GitHub >

github_iconTop Results From Across the Web

html - How to order the content generated by *NgFor in rows ...
I am trying to get the elements generated by *NgFor to be sorted into 3 elements per row. Currently this code puts all...
Read more >
[Solved]-Using Angular *ngFor in a CSS-Grid-Layout?
You can use row-gap, column-gap or gap instead. Regarding grid distribution, have you tried grid-template-rows or grid-template-columns: auto ?
Read more >
Padding problem at last element in every row when using ...
I'm currently facing a big issue in the library. The problem is the fxLayoutGap setting for grid likely designs but just as a...
Read more >
Angular Flex-Layout: Flexbox and Grid Layout ... - InDepth.Dev
In Angular, it is common for a view of a component to be divided into template HTML and stylesheet CSS. Since the layout...
Read more >
NgForOf - Angular
NgForOf uses the computed key to associate items in an iterable with DOM elements it produces for these items. A custom TrackByFunction is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found