Merge pull request #164 from t47io/fix-bound-event-listener
Fix bound listener
This commit is contained in:
commit
08d0b93135
19
dist/frappe-charts.esm.js
vendored
19
dist/frappe-charts.esm.js
vendored
@ -1312,8 +1312,6 @@ function prepareForExport(svg) {
|
|||||||
return container.innerHTML;
|
return container.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
let BOUND_DRAW_FN;
|
|
||||||
|
|
||||||
class BaseChart {
|
class BaseChart {
|
||||||
constructor(parent, options) {
|
constructor(parent, options) {
|
||||||
|
|
||||||
@ -1394,18 +1392,15 @@ class BaseChart {
|
|||||||
this.height = height - getExtraHeight(this.measures);
|
this.height = height - getExtraHeight(this.measures);
|
||||||
|
|
||||||
// Bind window events
|
// Bind window events
|
||||||
BOUND_DRAW_FN = this.boundDrawFn.bind(this);
|
this.boundDrawFn = () => this.draw(true);
|
||||||
window.addEventListener('resize', BOUND_DRAW_FN);
|
window.addEventListener('resize', this.boundDrawFn);
|
||||||
window.addEventListener('orientationchange', this.boundDrawFn.bind(this));
|
window.addEventListener('orientationchange', this.boundDrawFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
boundDrawFn() {
|
destroy() {
|
||||||
this.draw(true);
|
// Unbind window events
|
||||||
}
|
window.removeEventListener('resize', this.boundDrawFn);
|
||||||
|
window.removeEventListener('orientationchange', this.boundDrawFn);
|
||||||
unbindWindowEvents() {
|
|
||||||
window.removeEventListener('resize', BOUND_DRAW_FN);
|
|
||||||
window.removeEventListener('orientationchange', this.boundDrawFn.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has to be called manually
|
// Has to be called manually
|
||||||
|
|||||||
2
dist/frappe-charts.min.cjs.js
vendored
2
dist/frappe-charts.min.cjs.js
vendored
File diff suppressed because one or more lines are too long
2
dist/frappe-charts.min.cjs.js.map
vendored
2
dist/frappe-charts.min.cjs.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/frappe-charts.min.esm.js
vendored
2
dist/frappe-charts.min.esm.js
vendored
File diff suppressed because one or more lines are too long
2
dist/frappe-charts.min.esm.js.map
vendored
2
dist/frappe-charts.min.esm.js.map
vendored
File diff suppressed because one or more lines are too long
2
docs/assets/js/frappe-charts.min.js
vendored
2
docs/assets/js/frappe-charts.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -301,7 +301,7 @@
|
|||||||
chart.export();
|
chart.export();
|
||||||
|
|
||||||
// Unbind window-resize events
|
// Unbind window-resize events
|
||||||
chart.unbindWindowEvents();
|
chart.destroy();
|
||||||
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -7,8 +7,6 @@ import { getColor, isValidColor } from '../utils/colors';
|
|||||||
import { runSMILAnimation } from '../utils/animation';
|
import { runSMILAnimation } from '../utils/animation';
|
||||||
import { downloadFile, prepareForExport } from '../utils/export';
|
import { downloadFile, prepareForExport } from '../utils/export';
|
||||||
|
|
||||||
let BOUND_DRAW_FN;
|
|
||||||
|
|
||||||
export default class BaseChart {
|
export default class BaseChart {
|
||||||
constructor(parent, options) {
|
constructor(parent, options) {
|
||||||
|
|
||||||
@ -89,18 +87,15 @@ export default class BaseChart {
|
|||||||
this.height = height - getExtraHeight(this.measures);
|
this.height = height - getExtraHeight(this.measures);
|
||||||
|
|
||||||
// Bind window events
|
// Bind window events
|
||||||
BOUND_DRAW_FN = this.boundDrawFn.bind(this);
|
this.boundDrawFn = () => this.draw(true);
|
||||||
window.addEventListener('resize', BOUND_DRAW_FN);
|
window.addEventListener('resize', this.boundDrawFn);
|
||||||
window.addEventListener('orientationchange', this.boundDrawFn.bind(this));
|
window.addEventListener('orientationchange', this.boundDrawFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
boundDrawFn() {
|
destroy() {
|
||||||
this.draw(true);
|
// Unbind window events
|
||||||
}
|
window.removeEventListener('resize', this.boundDrawFn);
|
||||||
|
window.removeEventListener('orientationchange', this.boundDrawFn);
|
||||||
unbindWindowEvents() {
|
|
||||||
window.removeEventListener('resize', BOUND_DRAW_FN);
|
|
||||||
window.removeEventListener('orientationchange', this.boundDrawFn.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has to be called manually
|
// Has to be called manually
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user