Add timed forced rebuilding. #17

This commit is contained in:
Thomas Lovén 2019-03-20 10:02:37 +01:00
parent 226f86debe
commit d4acb7de58
2 changed files with 9 additions and 1 deletions

View File

@ -165,6 +165,7 @@ cards:
max_width: <max width>
min_height: <min height>
ltr: <ltr>
rebuild: <rebuild>
cards:
<cards>
```
@ -214,6 +215,11 @@ Optional. Default: false
If set to true, columns will be placed right-to-left.
### `<rebuild>`
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.
### `<cards>`
Required.

View File

@ -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() {