mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Fix history jump (#792)
This commit is contained in:
parent
f2358acf2d
commit
728d781843
@ -1,5 +1,5 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
||||||
<link rel="import" href="../../bower_components/iron-resizable-behavior/iron-resizable-behavior.html">
|
<link rel="import" href="../../bower_components/polymer/lib/utils/debounce.html">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
{
|
{
|
||||||
@ -19,8 +19,7 @@
|
|||||||
return !isNaN(parsed) && isFinite(parsed) ? parsed : null;
|
return !isNaN(parsed) && isFinite(parsed) ? parsed : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
class StateHistoryChartLine extends
|
class StateHistoryChartLine extends Polymer.Element {
|
||||||
Polymer.mixinBehaviors([Polymer.IronResizableBehavior], Polymer.Element) {
|
|
||||||
static get is() { return 'state-history-chart-line'; }
|
static get is() { return 'state-history-chart-line'; }
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
@ -55,9 +54,25 @@
|
|||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
this._isAttached = true;
|
this._isAttached = true;
|
||||||
this.drawChart();
|
this.drawChart();
|
||||||
this.addEventListener('iron-resize', () => {
|
|
||||||
setTimeout(() => this.drawChart(), 10);
|
this._resizeListener = () => {
|
||||||
});
|
this._debouncer = Polymer.Debouncer.debounce(
|
||||||
|
this._debouncer,
|
||||||
|
Polymer.Async.timeOut.after(10),
|
||||||
|
() => {
|
||||||
|
if (this._isAttached) {
|
||||||
|
this.drawChart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
window.addEventListener('resize', this._resizeListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this._isAttached = false;
|
||||||
|
window.removeEventListener('resize', this._resizeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataChanged() {
|
dataChanged() {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
<link rel="import" href="../../bower_components/iron-resizable-behavior/iron-resizable-behavior.html">
|
<link rel="import" href="../../bower_components/polymer/lib/utils/debounce.html">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
class StateHistoryChartTimeline extends
|
class StateHistoryChartTimeline extends Polymer.Element {
|
||||||
Polymer.mixinBehaviors([Polymer.IronResizableBehavior], Polymer.Element) {
|
|
||||||
static get is() { return 'state-history-chart-timeline'; }
|
static get is() { return 'state-history-chart-timeline'; }
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
@ -23,9 +22,25 @@ class StateHistoryChartTimeline extends
|
|||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
this._isAttached = true;
|
this._isAttached = true;
|
||||||
this.drawChart();
|
this.drawChart();
|
||||||
this.addEventListener('iron-resize', () => {
|
|
||||||
setTimeout(() => this.drawChart(), 10);
|
this._resizeListener = () => {
|
||||||
});
|
this._debouncer = Polymer.Debouncer.debounce(
|
||||||
|
this._debouncer,
|
||||||
|
Polymer.Async.timeOut.after(10),
|
||||||
|
() => {
|
||||||
|
if (this._isAttached) {
|
||||||
|
this.drawChart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
window.addEventListener('resize', this._resizeListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this._isAttached = false;
|
||||||
|
window.removeEventListener('resize', this._resizeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataChanged() {
|
dataChanged() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user