Skip to content

Commit

Permalink
Better compatibility with ancient ios devices
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Jan 27, 2022
1 parent 537bb11 commit 41f3f05
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
29 changes: 19 additions & 10 deletions fold-entity-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,15 @@ class FoldEntityRow extends s {
}, 100);
}
const el = this.shadowRoot.querySelector("#measure");
this.observer = new ResizeObserver(() => {
this.maxheight = el.scrollHeight;
});
this.observer.observe(el);
try {
this.observer = new ResizeObserver(() => {
this.maxheight = el.scrollHeight;
});
this.observer.observe(el);
}
catch (_e) {
this.maxheight = 1e6;
}
}
connectedCallback() {
super.connectedCallback();
Expand Down Expand Up @@ -459,32 +464,36 @@ class FoldEntityRow extends s {
#items {
padding: 0;
margin: 0;
overflow: hidden;
transition: max-height 0.2s ease-in-out;
height: 100%;
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
#items.clip {
overflow: clip;
}
#measure {
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
#measure > * {
margin: 8px 0;
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
#measure > *:last-child {
margin-bottom: 0;
}
#measure > div * {
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
#head > *:first-child {
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
`;
}
Expand Down
28 changes: 18 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,14 @@ class FoldEntityRow extends LitElement {
}

const el = this.shadowRoot.querySelector("#measure") as HTMLElement;
this.observer = new ResizeObserver(() => {
this.maxheight = el.scrollHeight;
});
this.observer.observe(el);
try {
this.observer = new ResizeObserver(() => {
this.maxheight = el.scrollHeight;
});
this.observer.observe(el);
} catch (_e) {
this.maxheight = 1e6;
}
}

connectedCallback(): void {
Expand Down Expand Up @@ -374,32 +378,36 @@ class FoldEntityRow extends LitElement {
#items {
padding: 0;
margin: 0;
overflow: hidden;
transition: max-height 0.2s ease-in-out;
height: 100%;
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
#items.clip {
overflow: clip;
}
#measure {
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
#measure > * {
margin: 8px 0;
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
#measure > *:last-child {
margin-bottom: 0;
}
#measure > div * {
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
#head > *:first-child {
overflow: clip visible;
overflow-x: clip;
overflow-y: visible;
}
`;
}
Expand Down
13 changes: 13 additions & 0 deletions test/views/2_cooperation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ cards:
type: custom:fold-entity-row
head: { entity: light.bed_light }
open: true
- type: entities
entities:
- type: custom:hui-entity-filter-card
entities:
- light.bed_light
- light.ceiling_lights
- light.kitchen_lights
state_filter:
- "on"
card:
type: custom:fold-entity-row
head: { type: section, label: Section }
open: true

- type: vertical-stack
cards:
Expand Down

0 comments on commit 41f3f05

Please sign in to comment.