Fix safari not rendering history graph (#7025)

This commit is contained in:
Bram Kragten 2020-09-16 17:20:49 +02:00 committed by GitHub
parent 9b25a54a47
commit a8a1563586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,12 +62,22 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
this.drawChart(); this.drawChart();
} }
ready() {
super.ready();
// safari doesn't always render the canvas when we animate it, so we remove overflow hidden when the animation is complete
this.addEventListener("transitionend", () => {
this.style.overflow = "auto";
});
}
dataChanged() { dataChanged() {
this.drawChart(); this.drawChart();
} }
_onRenderedChanged(rendered) { _onRenderedChanged(rendered) {
if (rendered) this.animateHeight(); if (rendered) {
this.animateHeight();
}
} }
animateHeight() { animateHeight() {
@ -79,15 +89,15 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
} }
drawChart() { drawChart() {
if (!this._isAttached) {
return;
}
const unit = this.unit; const unit = this.unit;
const deviceStates = this.data; const deviceStates = this.data;
const datasets = []; const datasets = [];
let endTime; let endTime;
if (!this._isAttached) {
return;
}
if (deviceStates.length === 0) { if (deviceStates.length === 0) {
return; return;
} }