Skip to content

Commit

Permalink
Improve nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Jan 29, 2020
1 parent c0f8304 commit 001de4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion layout-card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class LayoutCard extends LitElement {
this.columns = [];
}

connectedCallback() {
super.connectedCallback();
this.place_cards(this.clientWidth);
}
async firstUpdated() {
window.addEventListener('resize', () => this.place_cards());
window.addEventListener('hass-open-menu', () => setTimeout(() => this.place_cards(), 100));
Expand Down Expand Up @@ -96,8 +100,8 @@ class LayoutCard extends LitElement {
return;
if(width !== undefined)
this.lastWidth = width;
else
width = this.lastWidth;
this.lastWidth = this.clientWidth || this.lastWidth;
width = this.lastWidth;
this.columns = buildLayout(
this.cards,
width || 1,
Expand Down Expand Up @@ -238,4 +242,5 @@ class LayoutCard extends LitElement {

}

customElements.define("layout-card", LayoutCard);
if(!customElements.get("layout-card"))
customElements.define("layout-card", LayoutCard);

0 comments on commit 001de4f

Please sign in to comment.