From: Robert Konigsberg Date: Sun, 17 Oct 2010 00:32:55 +0000 (-0400) Subject: nit: s/undefined/null X-Git-Tag: v1.0.0~613^2~4 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=eeab5025da187d3fb284353fd2ba7d69e5d95d39;hp=c65f2303664330f03787d4e0bc7da5f2d9b4bc5f;p=dygraphs.git nit: s/undefined/null bug: consistent rules for defining when zoom is horizontal or vertical. --- diff --git a/dygraph.js b/dygraph.js index b8ce5e2..375f9c9 100644 --- a/dygraph.js +++ b/dygraph.js @@ -761,6 +761,7 @@ Dygraph.prototype.createDragInterface_ = function() { var dragStartY = null; var dragEndX = null; var dragEndY = null; + var dragDirection = null; var prevEndX = null; var prevEndY = null; var prevDragDirection = null; @@ -793,7 +794,7 @@ Dygraph.prototype.createDragInterface_ = function() { var yDelta = Math.abs(dragStartY - dragEndY); // drag direction threshold for y axis is twice as large as x axis - var dragDirection = (xDelta < yDelta / 2) ? Dygraph.VERTICAL : Dygraph.HORIZONTAL; + dragDirection = (xDelta < yDelta / 2) ? Dygraph.VERTICAL : Dygraph.HORIZONTAL; self.drawZoomRect_(dragDirection, dragStartX, dragEndX, dragStartY, dragEndY, prevDragDirection, prevEndX, prevEndY); @@ -920,10 +921,10 @@ Dygraph.prototype.createDragInterface_ = function() { } } - if (regionWidth >= 10 && regionWidth > regionHeight) { + if (regionWidth >= 10 && dragDirection == Dygraph.HORIZONTAL) { self.doZoomX_(Math.min(dragStartX, dragEndX), Math.max(dragStartX, dragEndX)); - } else if (regionHeight >= 10 && regionHeight > regionWidth){ + } else if (regionHeight >= 10 && dragDirection == Dygraph.VERTICAL){ self.doZoomY_(Math.min(dragStartY, dragEndY), Math.max(dragStartY, dragEndY)); } else { diff --git a/tests/zoom.html b/tests/zoom.html index 353be3b..c3b0e2d 100644 --- a/tests/zoom.html +++ b/tests/zoom.html @@ -84,8 +84,8 @@ function unzoomGraph() { g.updateOptions({ - dateWindow: undefined, - valueRange: undefined + dateWindow: null, + valueRange: null }); }