From d4acb7de5880159154e9c8709a881524eceb6a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Wed, 20 Mar 2019 10:02:37 +0100 Subject: [PATCH] Add timed forced rebuilding. #17 --- README.md | 6 ++++++ layout-card.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 84998e8..66effd8 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,7 @@ cards: max_width: min_height: ltr: + rebuild: cards: ``` @@ -214,6 +215,11 @@ Optional. Default: false If set to true, columns will be placed right-to-left. +### `` +Optional. Default: false + +If set, a rebuild of the layout will be triggered after this many milliseconds. May be useful if your layout looks different after a page reload or when you return to the view, but it will cause your screen to flash once. + ### `` Required. diff --git a/layout-card.js b/layout-card.js index 10d404f..d36e92a 100644 --- a/layout-card.js +++ b/layout-card.js @@ -7,7 +7,7 @@ class LayoutCard extends cardTools.LitElement { this.layout = config.layout || 'auto'; this.minCols = config.column_num || 1; this.maxCols = config.max_columns || 100; - this.colWidth = config.column_width || 300; + this.colWidth = config.column_width || 400; this.maxWidth = config.max_width || 500; this.minHeight = config.min_height || 5; this.rtl = config.rtl || false; @@ -16,6 +16,8 @@ class LayoutCard extends cardTools.LitElement { window.addEventListener('resize', () => this.build()); window.addEventListener('hass-open-menu', () => setTimeout(() => this.build(), 100)); window.addEventListener('hass-close-menu', () => setTimeout(() => this.build(), 100)); + if(config.rebuild) + window.setTimeout(() => this.build(), config.rebuild); } render() {