From: Klaus Weidner Date: Fri, 27 Jul 2012 22:53:06 +0000 (-0700) Subject: Don't clear overlay on mouseup if not zooming. X-Git-Tag: v1.0.0~209^2^2~1 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=214083b469aec7f51223ec5c1532924d75c6eb2f;p=dygraphs.git 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. --- 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;