From: Dan Vanderkam Date: Sun, 26 Feb 2012 02:45:28 +0000 (-0500) Subject: Fix Issue 279: Strange animations when zooming animations are enabled and double... X-Git-Tag: v1.0.0~302 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=421f177336b1dbd195952cfee457483ec9f479ba;p=dygraphs.git Fix Issue 279: Strange animations when zooming animations are enabled and double click zooming --- diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index b6c19d2..4d23eff 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -329,9 +329,11 @@ Dygraph.Interaction.endZoom = function(event, g, context) { if (regionWidth >= 10 && context.dragDirection == Dygraph.HORIZONTAL) { g.doZoomX_(Math.min(context.dragStartX, context.dragEndX), Math.max(context.dragStartX, context.dragEndX)); + context.cancelNextDblclick = true; } else if (regionHeight >= 10 && context.dragDirection == Dygraph.VERTICAL) { g.doZoomY_(Math.min(context.dragStartY, context.dragEndY), Math.max(context.dragStartY, context.dragEndY)); + context.cancelNextDblclick = true; } else { g.clearZoomRect_(); } @@ -548,6 +550,10 @@ Dygraph.Interaction.defaultModel = { // Disable zooming out if panning. dblclick: function(event, g, context) { + if (context.cancelNextDblclick) { + context.cancelNextDblclick = false; + return; + } if (event.altKey || event.shiftKey) { return; } diff --git a/dygraph.js b/dygraph.js index 045c394..c60eccc 100644 --- a/dygraph.js +++ b/dygraph.js @@ -851,12 +851,12 @@ Dygraph.prototype.createInterface_ = function() { var dygraph = this; this.mouseMoveHandler = function(e) { - dygraph.mouseMove_(e); + dygraph.mouseMove_(e); }; Dygraph.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler); this.mouseOutHandler = function(e) { - dygraph.mouseOut_(e); + dygraph.mouseOut_(e); }; Dygraph.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler); @@ -1120,6 +1120,7 @@ Dygraph.prototype.createDragInterface_ = function() { prevEndX: null, // pixel coordinates prevEndY: null, // pixel coordinates prevDragDirection: null, + cancelNextDblclick: false, // see comment in dygraph-interaction-model.js // The value on the left side of the graph when a pan operation starts. initialLeftmostDate: null, @@ -1156,6 +1157,7 @@ Dygraph.prototype.createDragInterface_ = function() { context.py = Dygraph.findPosY(g.canvas_); context.dragStartX = g.dragGetX_(event, context); context.dragStartY = g.dragGetY_(event, context); + context.cancelNextDblclick = false; } };