From 572d9ebab9aed08845374d1508b4c6e2f0e95a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Sun, 11 Nov 2018 20:16:28 +0100 Subject: [PATCH] Fix problem when changing panel --- layout-card.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/layout-card.js b/layout-card.js index 840b417..3a4573d 100644 --- a/layout-card.js +++ b/layout-card.js @@ -44,6 +44,7 @@ class LayoutCard extends Polymer.Element { this.config.min_height = this.config.minheight || 5; this.config.column_width = this.config.column_width || 300; this.config.layout = this.config.layout || 'auto'; + this.config.max_columns = this.config.max_columns || 100; window.addEventListener('resize', () => this._updateColumns()); window.addEventListener('hass-open-menu', () => setTimeout(() => this._updateColumns(), 10)); @@ -66,8 +67,9 @@ class LayoutCard extends Polymer.Element { } else { let colWidth = this.config.column_width || 300; numcols = Math.max(1, - Math.floor(this.$.columns.clientWidth/this.config.column_width)); + this.$ ? Math.floor(this.$.columns.clientWidth/this.config.column_width) : 0); } + numcols = Math.max(numcols, this.config.max_columns); if(numcols != this.colnum) { this.colnum = numcols; this._build(); @@ -75,6 +77,7 @@ class LayoutCard extends Polymer.Element { } _build() { + if(!this.$) return; const root = this.$.columns; while(root.lastChild) root.removeChild(root.lastChild);