Fix Issue 279: Strange animations when zooming animations are enabled and double...
[dygraphs.git] / dygraph-interaction-model.js
index 2790633..4d23eff 100644 (file)
@@ -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_();
   }
@@ -499,6 +501,9 @@ Dygraph.Interaction.endTouch = function(event, g, context) {
 Dygraph.Interaction.defaultModel = {
   // Track the beginning of drag events
   mousedown: function(event, g, context) {
+    // Right-click should not initiate a zoom.
+    if (event.button && event.button == 2) return;
+
     context.initializeMouseDown(event, g, context);
 
     if (event.altKey || event.shiftKey) {
@@ -545,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;
     }