Browse Source

added start and end callback for zoom

pull/569/head
michalkop93 10 years ago
parent
commit
708c9d5913
  1. 6
      c3.js
  2. 8
      c3.min.js
  3. 2
      src/config.js
  4. 4
      src/zoom.js

6
c3.js

@ -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);

8
c3.min.js vendored

File diff suppressed because one or more lines are too long

2
src/config.js

@ -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
src/zoom.js

@ -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);

Loading…
Cancel
Save