Play well with dynamic loaders

This commit is contained in:
Thomas Lovén 2019-02-15 09:17:51 +01:00
parent a313b78a29
commit 616f745bbd

View File

@ -44,6 +44,12 @@ class LayoutCard extends Polymer.Element {
setTimeout(() => this._updateColumns(), 10); setTimeout(() => this._updateColumns(), 10);
} }
connectedCallback() {
super.connectedCallback();
this._updateColumns();
this._build();
}
_updateColumns() { _updateColumns() {
if (this.parentElement && this.parentElement.id === "view") if (this.parentElement && this.parentElement.id === "view")
{ {
@ -59,7 +65,7 @@ class LayoutCard extends Polymer.Element {
} else { } else {
let colWidth = this.config.column_width || 300; let colWidth = this.config.column_width || 300;
numcols = Math.max(1, numcols = Math.max(1,
this.$ ? Math.floor(this.$.columns.clientWidth/this.config.column_width) : 0); this.$ ? Math.floor(this.parentElement.clientWidth/this.config.column_width) : 0);
} }
numcols = Math.min(numcols, this.config.max_columns); numcols = Math.min(numcols, this.config.max_columns);
if(numcols != this.colnum) { if(numcols != this.colnum) {