forked from trading-peter/chart-elements
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresize-mixin.js
More file actions
33 lines (29 loc) · 773 Bytes
/
resize-mixin.js
File metadata and controls
33 lines (29 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* Listen for the iron-resize event to re-render the chart.
* @polymer
* @mixinFunction
*/
export const ResizeMixin = function(superClass) {
return class extends superClass {
connectedCallback() {
super.connectedCallback();
this._boundOnResize = this._onResize.bind(this);
window.addEventListener('resize', this._boundOnResize);
}
disconnectedCallback() {
super.disconnectedCallback();
window.removeEventListener('resize', this._boundOnResize);
}
_onResize() {
this._queue();
}
// This is a public method the user can call if they've
// changed our dimensions with CSS.
resize() {
if (this.chart) {
this.chart.resize();
this.chart.render(true);
}
}
}
};