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/iron-resizable-behavior/iron-resizable-behavior.html">
|
||||
<link rel="import" href="../../bower_components/polymer/lib/utils/debounce.html">
|
||||
|
||||
<script>
|
||||
{
|
||||
@ -19,8 +19,7 @@
|
||||
return !isNaN(parsed) && isFinite(parsed) ? parsed : null;
|
||||
}
|
||||
|
||||
class StateHistoryChartLine extends
|
||||
Polymer.mixinBehaviors([Polymer.IronResizableBehavior], Polymer.Element) {
|
||||
class StateHistoryChartLine extends Polymer.Element {
|
||||
static get is() { return 'state-history-chart-line'; }
|
||||
static get properties() {
|
||||
return {
|
||||
@ -55,9 +54,25 @@
|
||||
super.connectedCallback();
|
||||
this._isAttached = true;
|
||||
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() {
|
||||
|
@ -1,9 +1,8 @@
|
||||
<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>
|
||||
class StateHistoryChartTimeline extends
|
||||
Polymer.mixinBehaviors([Polymer.IronResizableBehavior], Polymer.Element) {
|
||||
class StateHistoryChartTimeline extends Polymer.Element {
|
||||
static get is() { return 'state-history-chart-timeline'; }
|
||||
static get properties() {
|
||||
return {
|
||||
@ -23,9 +22,25 @@ class StateHistoryChartTimeline extends
|
||||
super.connectedCallback();
|
||||
this._isAttached = true;
|
||||
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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user