Giter Site home page Giter Site logo

Comments (7)

wynfred avatar wynfred commented on May 22, 2024 3

Hi,
You can try this:
@ViewChild(NgxMasonryComponent, {static: false}) masonry: NgxMasonryComponent;
And use the reloadItems function without display:none, in the filter function:

this.portfolioItems = this.items.filter(it => (it.cat === cat || cat === 'all'));
setTimeout(() => this.masonry._msnry.reloadItems())
this.updateMasonryLayout = Date.now().toString();

from ngx-masonry.

barbhackk avatar barbhackk commented on May 22, 2024 1

Hi,
You can try this:
@ViewChild(NgxMasonryComponent, {static: false}) masonry: NgxMasonryComponent;
And use the reloadItems function without display:none, in the filter function:

this.portfolioItems = this.items.filter(it => (it.cat === cat || cat === 'all'));
setTimeout(() => this.masonry._msnry.reloadItems())
this.updateMasonryLayout = Date.now().toString();

Thank you it's perfect... I will never have thought of it alone.
You got me out of a sticky situation! Thank you so much.

from ngx-masonry.

dandohotaru avatar dandohotaru commented on May 22, 2024 1

first take

having hit the wall with the same problem the other day, managed to make it work in conjunction with the proposed updateLayout field and reloadItems (stackblitz)

  <ngx-masonry [options]="options" [updateLayout]="store.stamp">
    <div ngxMasonryItem *ngFor="let item of store.refined; let i = index">
  @ViewChild(NgxMasonryComponent, {static: false}) 
  public masonry: NgxMasonryComponent;

  public filter(category: string){
    this.store.refined = this.store.cached
      .filter(p => p.category == category || category == 'all');
    this.store.stamp = new Date();
    this.masonry.reloadItems();
  }

second take

this solution though seemed a bit hacky to have to trigger a change detection just to to force masonry to redraw itself.
in the end came up with another solution based on reloadItems and layout without the need of an updateLayout field (stackblitz)

  <ngx-masonry [options]="options">
    <div ngxMasonryItem *ngFor="let item of store.refined; let i = index">
  @ViewChild(NgxMasonryComponent, {static: false}) 
  public masonry: NgxMasonryComponent;

  public filter(category: string){
    this.store.refined = this.store.cached
      .filter(p => p.category == category || category == 'all');

    setTimeout(() => {
      this.masonry._msnry.reloadItems();
      this.masonry._msnry.layout();
    });
  }

adding the link to masonry layout docs just for further references
https://masonry.desandro.com/methods.html

from ngx-masonry.

wynfred avatar wynfred commented on May 22, 2024

Can you try removing the item from the array instead of set it to display:none, or use the itemSelector option?

from ngx-masonry.

barbhackk avatar barbhackk commented on May 22, 2024

Can you try removing the item from the array instead of set it to display:none, or use the itemSelector option?

Hi,

If I use removing the item, when I want to display the items that have been hidden previously, it is added to the following.

The itemSelector don't work. I am forced to use 'ngxMasonryItem'

You can look at my code on this page :
https://angular-7wyfeh.stackblitz.io for App
https://stackblitz.com/edit/angular-7wyfeh for Edit

from ngx-masonry.

barbhackk avatar barbhackk commented on May 22, 2024

Can you try removing the item from the array instead of set it to display:none, or use the itemSelector option?

Hi,

If I use removing the item, when I want to display the items that have been hidden previously, it is added to the following.

The itemSelector don't work. I am forced to use 'ngxMasonryItem'

You can look at my code on this page :
https://angular-7wyfeh.stackblitz.io for App
https://stackblitz.com/edit/angular-7wyfeh for Edit

Any solution ? Thanks.

from ngx-masonry.

zeeshanshanif avatar zeeshanshanif commented on May 22, 2024

Hi,
You can try this:
@ViewChild(NgxMasonryComponent, {static: false}) masonry: NgxMasonryComponent;
And use the reloadItems function without display:none, in the filter function:

this.portfolioItems = this.items.filter(it => (it.cat === cat || cat === 'all'));
setTimeout(() => this.masonry._msnry.reloadItems())
this.updateMasonryLayout = Date.now().toString();

how it works without using filter just show items in sequence as they are in array?

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.