Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] Fix of chart resize in Safari and Firefox #136

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions packages/v3/src/esp-entity-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,43 @@ export class ChartElement extends LitElement {
maintainAspectRatio: false,
},
});
this.updateStylesIfExpanded();
}
// since the :host-context(.expanded) selector is not supported in Safari and Firefox we need to use JS to apply styles
// whether the parent element is expanded or not
updateStylesIfExpanded() {
const parentElement = this.parentElement;
const expandedClass = "expanded";

const applyStyles = () => {
if (parentElement && parentElement.classList.contains(expandedClass)) {
this.style.height = "240px";
this.style.opacity = "0.5";
} else {
this.style.height = "42px";
this.style.opacity = "0.1";
}
};

applyStyles();

// Observe class changes
const observer = new MutationObserver(applyStyles);
if (parentElement)
observer.observe(parentElement, {
attributes: true,
attributeFilter: ["class"],
});
}

static get styles() {
return css`
:host {
position: absolute;
left: 24px;
height: 42px !important;
height: 42px;
width: calc(100% - 42px);
z-index: -100;
opacity: 0.1;
}
:host-context(.expanded) {
height: 240px !important;
opacity: 0.5;
}
`;
}
Expand Down
Loading