X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-interaction-model.js;h=38e63d941daaabbc277e4909aeef56bf4ee9427b;hb=4d402efd2ad8318651a7fa809133a47a17db1288;hp=b1981d77ce9ed2460f063f73e660e4115a97371a;hpb=b04888ccae2e78f4b1113e3904e2828d8dcaed08;p=dygraphs.git diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index b1981d7..38e63d9 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -349,14 +349,20 @@ Dygraph.Interaction.endZoom = function(event, g, context) { if (regionWidth >= 10 && context.dragDirection == Dygraph.HORIZONTAL) { var left = Math.min(context.dragStartX, context.dragEndX), right = Math.max(context.dragStartX, context.dragEndX); - g.doZoomX_(Math.max(left, plotArea.x), - Math.min(right, plotArea.x + plotArea.w)); + left = Math.max(left, plotArea.x); + right = Math.min(right, plotArea.x + plotArea.w); + if (left < right) { + g.doZoomX_(left, right); + } context.cancelNextDblclick = true; } else if (regionHeight >= 10 && context.dragDirection == Dygraph.VERTICAL) { var top = Math.min(context.dragStartY, context.dragEndY), bottom = Math.max(context.dragStartY, context.dragEndY); - g.doZoomY_(Math.max(top, plotArea.y), - Math.min(bottom, plotArea.y + plotArea.h)); + top = Math.max(top, plotArea.y); + bottom = Math.min(bottom, plotArea.y + plotArea.h); + if (top < bottom) { + g.doZoomY_(top, bottom); + } context.cancelNextDblclick = true; } else { if (context.zoomMoved) g.clearZoomRect_();