Commit 708c9d59 authored by michalkop93's avatar michalkop93

added start and end callback for zoom

parent f1f62db1
......@@ -878,6 +878,8 @@
zoom_extent: undefined,
zoom_privileged: false,
zoom_onzoom: function () {},
zoom_onzoomstart: function () {},
zoom_onzoomend: function () {},
interaction_enabled: true,
onmouseover: function () {},
onmouseout: function () {},
......@@ -4951,6 +4953,7 @@
$$.zoom = d3.behavior.zoom()
.on("zoomstart", function () {
$$.zoom.altDomain = d3.event.sourceEvent.altKey ? $$.x.orgDomain() : null;
config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent);
})
.on("zoom", function () {
// prevZoomTranslate is needed for the fix of unexpected zoom.translate after remaining zoom
......@@ -4960,6 +4963,9 @@
$$.redrawForZoom.call($$);
prevZoomTranslate = $$.zoom.translate();
wheeled = d3.event.sourceEvent.type === 'wheel';
})
.on('zoomend', function () {
config.zoom_onzoomend.call($$.api, $$.x.orgDomain());
});
$$.zoom.scale = function (scale) {
return config.axis_rotated ? this.y(scale) : this.x(scale);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,6 +11,8 @@ c3_chart_internal_fn.getDefaultConfig = function () {
zoom_extent: undefined,
zoom_privileged: false,
zoom_onzoom: function () {},
zoom_onzoomstart: function () {},
zoom_onzoomend: function () {},
interaction_enabled: true,
onmouseover: function () {},
onmouseout: function () {},
......
......@@ -4,6 +4,7 @@ c3_chart_internal_fn.initZoom = function () {
$$.zoom = d3.behavior.zoom()
.on("zoomstart", function () {
$$.zoom.altDomain = d3.event.sourceEvent.altKey ? $$.x.orgDomain() : null;
config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent);
})
.on("zoom", function () {
// prevZoomTranslate is needed for the fix of unexpected zoom.translate after remaining zoom
......@@ -13,6 +14,9 @@ c3_chart_internal_fn.initZoom = function () {
$$.redrawForZoom.call($$);
prevZoomTranslate = $$.zoom.translate();
wheeled = d3.event.sourceEvent.type === 'wheel';
})
.on('zoomend', function () {
config.zoom_onzoomend.call($$.api, $$.x.orgDomain());
});
$$.zoom.scale = function (scale) {
return config.axis_rotated ? this.y(scale) : this.x(scale);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment