Browse Source

feat: restore zoom.disableDefaultBahavior option

pull/2447/head
Yoshiya Hinosawa 6 years ago
parent
commit
0e81f5899d
  1. 1
      src/config.js
  2. 10
      src/zoom.js

1
src/config.js

@ -15,6 +15,7 @@ ChartInternal.prototype.getDefaultConfig = function () {
zoom_enabled: false,
zoom_initialRange: undefined,
zoom_type: 'scroll',
zoom_disableDefaultBehavior: false,
zoom_privileged: false,
zoom_rescale: false,
zoom_onzoom: function () {},

10
src/zoom.js

@ -22,7 +22,12 @@ ChartInternal.prototype.initZoom = function () {
var e = d3.event.sourceEvent;
if (e && e.type === "brush") { return; }
if (!config.zoom_disableDefaultBehavior) {
$$.redrawForZoom.call($$);
}
config.zoom_onzoom.call($$.api, $$.x.orgDomain());
})
.on('end', function () {
if (config.zoom_type !== 'scroll') {
@ -73,7 +78,7 @@ ChartInternal.prototype.initDragZoom = function () {
return;
}
const getZoomedDomain = selection => selection && selection.map(x => $$.x.invert(x))
const getZoomedDomain = selection => selection && selection.map(x => $$.x.invert(x));
const brush = $$.dragZoomBrush = d3.brushX()
.on("start", () => {
@ -95,7 +100,9 @@ ChartInternal.prototype.initDragZoom = function () {
const zoomedDomain = getZoomedDomain(d3.event.selection);
if (!config.zoom_disableDefaultBehavior) {
$$.api.zoom(zoomedDomain);
}
$$.svg
.select("." + CLASS.dragZoom)
@ -142,5 +149,4 @@ ChartInternal.prototype.redrawForZoom = function () {
if (d3.event.sourceEvent && d3.event.sourceEvent.type === 'mousemove') {
$$.cancelClick = true;
}
config.zoom_onzoom.call($$.api, x.orgDomain());
};

Loading…
Cancel
Save