Skip to content

Commit

Permalink
fix(subchart): fix subchart esm import failure
Browse files Browse the repository at this point in the history
Move .unbindZoomEvent() from zoom.ts --> interaction.ts

Fix #2255
  • Loading branch information
netil committed Aug 17, 2021
1 parent 0a0f039 commit ba6c2b5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
15 changes: 15 additions & 0 deletions src/ChartInternal/interactions/interaction.ts
Expand Up @@ -244,5 +244,20 @@ export default {

setDragStatus(isDragging: boolean): void {
this.state.dragging = isDragging;
},

/**
* Unbind zoom events
* @private
*/
unbindZoomEvent(): void {
const $$ = this;
const {$el: {eventRect, zoomResetBtn}} = $$;

eventRect
.on(".zoom", null)
.on(".drag", null);

zoomResetBtn?.style("display", "none");
}
};
15 changes: 0 additions & 15 deletions src/ChartInternal/interactions/zoom.ts
Expand Up @@ -41,21 +41,6 @@ export default {
}
},

/**
* Unbind zoom events
* @private
*/
unbindZoomEvent(): void {
const $$ = this;
const {$el: {eventRect, zoomResetBtn}} = $$;

eventRect
.on(".zoom", null)
.on(".drag", null);

zoomResetBtn?.style("display", "none");
},

/**
* Generate zoom
* @private
Expand Down
33 changes: 33 additions & 0 deletions test/esm/subchart-spec.ts
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
*/
/* eslint-disable */
/* global describe, beforeEach, it, expect */
import {expect} from "chai";
import bb, {line, subchart} from "../../src/index.esm";

describe("ESM subchart", function() {
let chart;

const args: any = {
data: {
columns: [
["data1", 30, 350, 300, 0, 100],
["data2", 200, 100, 140, 200, 150]
],
type: line()
},
subchart: {
enabled: subchart()
}
};

beforeEach(() => {
chart = bb.generate(args);
});

it("shouldn't throw error during zoom", () => {
expect(chart.subchart.show()).to.not.throw;
});
});

0 comments on commit ba6c2b5

Please sign in to comment.