Comments (7)
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.
Hi,
You can try this:
@ViewChild(NgxMasonryComponent, {static: false}) masonry: NgxMasonryComponent;
And use thereloadItems
function withoutdisplay: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.
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.
Can you try removing the item from the array instead of set it to display:none
, or use the itemSelector
option?
from ngx-masonry.
Can you try removing the item from the array instead of set it to
display:none
, or use theitemSelector
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.
Can you try removing the item from the array instead of set it to
display:none
, or use theitemSelector
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.
Hi,
You can try this:
@ViewChild(NgxMasonryComponent, {static: false}) masonry: NgxMasonryComponent;
And use thereloadItems
function withoutdisplay: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)
- 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.