From 214083b469aec7f51223ec5c1532924d75c6eb2f Mon Sep 17 00:00:00 2001 From: Klaus Weidner Date: Fri, 27 Jul 2012 15:53:06 -0700 Subject: [PATCH] Don't clear overlay on mouseup if not zooming. On endZoom, check if moveZoom was called since the last startZoom. If not, leave the overlay canvas alone, there's no zoom rectangle to erase. The default mouseup action unconditionally cleared the overlay canvas, this destroyed other things that may have been drawn there such as highlighted series, causing glitches for clickCallback use. --- dygraph-interaction-model.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index 9b7feb5..6f860c3 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -220,6 +220,7 @@ Dygraph.Interaction.endPan = function(event, g, context) { */ Dygraph.Interaction.startZoom = function(event, g, context) { context.isZooming = true; + context.zoomMoved = false; }; /** @@ -236,6 +237,7 @@ Dygraph.Interaction.startZoom = function(event, g, context) { * dragStartX/dragStartY/etc. properties). This function modifies the context. */ Dygraph.Interaction.moveZoom = function(event, g, context) { + context.zoomMoved = true; context.dragEndX = g.dragGetX_(event, context); context.dragEndY = g.dragGetY_(event, context); @@ -335,7 +337,7 @@ Dygraph.Interaction.endZoom = function(event, g, context) { Math.max(context.dragStartY, context.dragEndY)); context.cancelNextDblclick = true; } else { - g.clearZoomRect_(); + if (zoomMoved) g.clearZoomRect_(); } context.dragStartX = null; context.dragStartY = null; -- 2.7.4