forked from trading-peter/chart-elements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resize-behavior.html
36 lines (31 loc) · 1010 Bytes
/
resize-behavior.html
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
34
35
36
<script>
var ChartBehaviors = ChartBehaviors || {};
/** @polymerBehavior */
ChartBehaviors.ResizeBehavior = Polymer.dedupingMixin(function(superClass) {
return class extends superClass {
connectedCallback() {
super.connectedCallback();
this._boundOnIronResize = this._onIronResize.bind(this);
this.addEventListener('iron-resize', this._boundOnIronResize);
}
disconnectedCallback() {
super.disconnectedCallback();
this.removeEventListener('iron-resize', this._boundOnIronResize);
}
// If an iron-resizer changes our size and notifies us
// check to see if we have a height and if so, recreate
// the chart
_onIronResize() {
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);
}
}
}
});
</script>