From 616f745bbd93fc5bf669aff9a384703067282a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Fri, 15 Feb 2019 09:17:51 +0100 Subject: [PATCH] Play well with dynamic loaders --- layout-card.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/layout-card.js b/layout-card.js index d27bf27..47bd53b 100644 --- a/layout-card.js +++ b/layout-card.js @@ -44,6 +44,12 @@ class LayoutCard extends Polymer.Element { setTimeout(() => this._updateColumns(), 10); } + connectedCallback() { + super.connectedCallback(); + this._updateColumns(); + this._build(); + } + _updateColumns() { if (this.parentElement && this.parentElement.id === "view") { @@ -59,7 +65,7 @@ class LayoutCard extends Polymer.Element { } else { let colWidth = this.config.column_width || 300; 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); if(numcols != this.colnum) {