Skip to content

Commit

Permalink
fix(zoom): Fix to pass domain arg on onzoom
Browse files Browse the repository at this point in the history
Add omitted argument for onzoom option callback.

Fix #1109
  • Loading branch information
netil authored Nov 13, 2019
1 parent bb9f952 commit e1daae6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
9 changes: 8 additions & 1 deletion spec/api/api.zoom-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ describe("API zoom", function() {
let chart;

describe("zoom line chart #1", () => {
const spy = sinon.spy();

before(() => {
chart = util.generate({
data: {
Expand All @@ -21,7 +23,8 @@ describe("API zoom", function() {
]
},
zoom: {
enabled: true
enabled: true,
onzoom: spy
}
});
});
Expand All @@ -35,6 +38,10 @@ describe("API zoom", function() {

expect(domain[0]).to.be.equal(target[0]);
expect(domain[1]).to.be.equal(target[1]);

// onzoom callback has been called?
expect(spy.called).to.be.true;
expect(spy.args[0][0]).to.be.deep.equal(target);
});

it("should be zoomed properly again", () => {
Expand Down
20 changes: 11 additions & 9 deletions spec/interactions/zoom-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ describe("ZOOM", function() {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (spyOnZoomStart.called) {
expect(spyOnZoomStart.args[0][0].type).to.be.equal("mousedown");

util.fireEvent(eventRect, "mousemove", {
clientX: 100,
clientY: 150
Expand All @@ -138,17 +140,17 @@ describe("ZOOM", function() {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (spyOnZoom.called) {
if (spyOnZoom.called) {
util.fireEvent(eventRect, "mouseup", {
clientX: 100,
clientY: 150
}, chart);
expect(spyOnZoom.args[0][0]).to.be.deep.equal([0, 3]);

util.fireEvent(eventRect, "mouseup", {
clientX: 100,
clientY: 150
}, chart);

// call explicitly, due to mouseup isn't firing well programmatically.
chart.internal.onZoomEnd();
// call explicitly, due to mouseup isn't firing well programmatically.
chart.internal.onZoomEnd();

resolve("--> onzoom callback called!");
}
resolve("--> onzoom callback called!");
};
}, 500);
})
Expand Down
2 changes: 1 addition & 1 deletion src/api/api.zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const zoom = function(domainValue) {
});

$$.setZoomResetButton();
callFn($$.config.zoom_onzoom, resultDomain);
callFn($$.config.zoom_onzoom, $$.api, resultDomain);
} else {
resultDomain = $$.zoomScale ?
$$.zoomScale.domain() : $$.x.orgDomain();
Expand Down

0 comments on commit e1daae6

Please sign in to comment.