From: Dan Vanderkam Date: Wed, 8 Feb 2017 18:20:36 +0000 (-0500) Subject: Make dblclick event cancelable. (#840) X-Git-Tag: v2.1.0~8 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=aa0b189f8cb22d64ce65cc9b205c90f6e4fd1257;hp=0a31d41e94fae75808da6caa36e96fcdd40fd23f;p=dygraphs.git Make dblclick event cancelable. (#840) Add demo of how to restore the dygraphs 1.x zoom out behavior. --- diff --git a/src/dygraph-interaction-model.js b/src/dygraph-interaction-model.js index 349fd3e..494b638 100644 --- a/src/dygraph-interaction-model.js +++ b/src/dygraph-interaction-model.js @@ -706,7 +706,8 @@ DygraphInteraction.defaultModel = { // Give plugins a chance to grab this event. var e = { canvasx: context.dragEndX, - canvasy: context.dragEndY + canvasy: context.dragEndY, + cancelable: true, }; if (g.cascadeEvents_('dblclick', e)) { return; diff --git a/src/dygraph.js b/src/dygraph.js index d503669..61e96f7 100644 --- a/src/dygraph.js +++ b/src/dygraph.js @@ -1350,6 +1350,7 @@ Dygraph.prototype.resetZoom = function() { const zoomCallback = this.getFunctionOption('zoomCallback'); // TODO(danvk): merge this block w/ the code below. + // TODO(danvk): factor out a generic, public zoomTo method. if (!animatedZooms) { this.dateWindow_ = null; this.axes_.forEach(axis => { diff --git a/tests/old-yrange-behavior.html b/tests/old-yrange-behavior.html new file mode 100644 index 0000000..d70ff1a --- /dev/null +++ b/tests/old-yrange-behavior.html @@ -0,0 +1,64 @@ + + + + + Old y-axis range behavior + + + + + +

Old y-axis range behavior

+

In dygraphs 1.x, if you set a valueRange for the y-axis, zoomed in and then double-clicked to zoom out, then the chart would zoom out to the valueRange that you specified.

+

Starting with dygraphs 2, double-clicking will zoom out to the full range of the chart's data. This makes the x- and y-axes behave identically.

+

This demo shows you how to get the old behavior in dygraphs 2 using a plugin. View source to see how.

+ +
+
+ + + +