Enngage / ngx-masonry-gallery

Masonry gallery for Angular 14+
https://enngage.github.io/ngx-masonry-gallery/
MIT License
66 stars 10 forks source link

Support for dynamic width #2

Closed guillaumelachaud closed 5 years ago

guillaumelachaud commented 5 years ago

Hi!

It seems it's not possibly to set the image width dynamically. Is it expected ?

Thanks!

guillaumelachaud commented 5 years ago

My bad, actually it works. The example uses ngAfterViewInit(). On Angular 7 it throws an error:

ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'width: 174'. Current value: 'width: 192'.

Using ngOnInit(), everything works smoothly.

Enngage commented 5 years ago

Hi,

The ExpressionChangedAfterItHasBeenCheckedError is quite common in Angular and it really depends what you are doing in your code and how it translated to change detection. You could solve this issue by manually running detectChanges (https://angular.io/api/core/ChangeDetectorRef#detectchanges), but be aware of possible performance issues.