From 1e6142ad455156ee6d6403d1eb58e1156ecde467 Mon Sep 17 00:00:00 2001 From: bwyu Date: Thu, 12 Mar 2015 14:50:44 -0700 Subject: [PATCH] WTD-842: Fixing mouse click in a plot area gets interpreted as a marquee zoom with an extent of zero. --- platform/features/plot/src/SubPlot.js | 11 ++++++---- platform/features/plot/test/SubPlotSpec.js | 24 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/platform/features/plot/src/SubPlot.js b/platform/features/plot/src/SubPlot.js index 18ea559d40..450e71f5a7 100644 --- a/platform/features/plot/src/SubPlot.js +++ b/platform/features/plot/src/SubPlot.js @@ -151,11 +151,14 @@ define( Math.max(a[1], b[1]) - origin[1] ]; - // Push the new state onto the pan-zoom stack - panZoomStack.pushPanZoom(origin, dimensions); + // Proceed with zoom if zoom dimensions are non zeros + if (!(dimensions[0] === 0 && dimensions[1] === 0)) { + // Push the new state onto the pan-zoom stack + panZoomStack.pushPanZoom(origin, dimensions); - // Make sure tick marks reflect new bounds - updateTicks(); + // Make sure tick marks reflect new bounds + updateTicks(); + } } // Start with the right initial drawing bounds, diff --git a/platform/features/plot/test/SubPlotSpec.js b/platform/features/plot/test/SubPlotSpec.js index 4eb9b6342b..47fe7c7ff4 100644 --- a/platform/features/plot/test/SubPlotSpec.js +++ b/platform/features/plot/test/SubPlotSpec.js @@ -136,6 +136,30 @@ define( ); }); + it("disallows marquee zoom when start and end Marquee is at the same position", function () { + expect(mockPanZoomStack.pushPanZoom).not.toHaveBeenCalled(); + + // Simulate a marquee zoom. Note that the mockElement + // is 100 by 100 and starts at 10,20 + subplot.startMarquee({ + target: mockElement, + clientX: 60, + clientY: 45 + }); + subplot.hover({ + target: mockElement, + clientX: 75, + clientY: 85 + }); + subplot.endMarquee({ + target: mockElement, + clientX: 60, + clientY: 45 + }); + + expect(mockPanZoomStack.pushPanZoom).not.toHaveBeenCalled(); + }); + it("provides access to a drawable object", function () { expect(typeof subplot.getDrawingObject()).toEqual('object'); });