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.

bug: sometimes grid column goes into one

See original GitHub issue

Hello!

Sorry again, I am opening this issue again, that 1 grid issue getting more buggy. We are seeing this problem so frequently, I would like to know source of this problem and I hope to help you to figure out this together.

Here goes my implementation

<ngx-masonry class="my-50" [options]="{gutter: gutter}" (layoutComplete)="layoutCompleted($event)">
  <div ngxMasonryItem class="masonry-item" *ngFor="let idea of ideas"
    [style.width]="cardWidth"
    [style.margin-bottom.px]="gutter">
    <job-hub-idea-board-card [editable]="editable"
                             [selectable]="selectable"
                             [clickable]="clickable"
                             [idea]="idea"
                             [isCustomer]="isCustomer"
                             (view)="view($event)"
                             (edit)="edit.emit($event)"
                             (delete)="delete.emit($event)"></job-hub-idea-board-card>
  </div>
</ngx-masonry>
<p class="d-flex align-items-center justify-content-center text-primary" *ngIf="hasPending">Loading
  {{ ideas.length > loaded ? ideas.length - loaded : loaded - ideas.length }} more images...
  <span class="d-inline-block ml-10 px-10 py-10 position-relative"><job-hub-spinner diameter="20"></job-hub-spinner></span>
</p>
export class IdeaBoardComponent implements OnInit {

  @Input() ideas: Idea[] = [];
  @Input() gutter = 20;
  @Input() col = 4;
  @ViewChild(NgxMasonryComponent) masonry: NgxMasonryComponent;

  loaded = 0;
  cardWidth;

  get hasPending(): boolean {
    return this.ideas.length > 0 && Boolean(this.loaded < this.ideas.length);
  }

  constructor(
    private sanitizer: DomSanitizer
  ) { }

  ngOnInit(): void {
    this.cardWidth = this.sanitizer.bypassSecurityTrustStyle(`calc((100% - ${(this.col - 1) * this.gutter}px) / ${this.col}`);
  }

  layoutCompleted(e) {
    if (this.loaded > this.ideas.length) {
      this.loaded = this.ideas.length;
      return;
    }
    if (e && e.length === 1) {
      this.loaded++;
    }
  }

  reset() {
    this.masonry.reloadItems();
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wynfredcommented, May 28, 2020

the native masonry functions and options may help - https://masonry.desandro.com/options.html

If you can put a simplified version on stackblitz I could help you debug it.

0reactions
webcat12345commented, May 27, 2020

Actually calling those two functions is maybe resolving that 1 column issue but grid is completely messy. I am trying some other methods on it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

grid-column doesn't work? [duplicate]
Your problem is that your grid is the 'main' element and 'download_desc' is within the 'download' section tag. Try moving:
Read more >
CSS Grid Gotchas And Stumbling Blocks
A true grid is two-dimensional. The two dimensions are rows and columns, and with grid layout you can control both at once. With...
Read more >
Bug with sorting columns in grid with detail template
If you have a nested template, it becomes impossible to customize the column sorting and you have to disable sorting for the entire...
Read more >
Auto-placement in grid layout - CSS: Cascading Style Sheets
In my example I am allowing auto-placement to place the items, however I have classes that start a dt in column 1, and...
Read more >
ERROR while exporting grid data to excel
and I have the below code, and which is containing a grid and the data getting loaded based on the "Status" dropdown selection....
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