diff --git a/src/plugins/plot/src/plot/MCTPlotController.js b/src/plugins/plot/src/plot/MCTPlotController.js index d050bd2b6b..5930d3e35d 100644 --- a/src/plugins/plot/src/plot/MCTPlotController.js +++ b/src/plugins/plot/src/plot/MCTPlotController.js @@ -220,6 +220,7 @@ define([ return; } this.marquee.end = this.positionOverPlot; + this.marquee.endPixels = this.positionOverElement; }; MCTPlotController.prototype.startMarquee = function ($event) { @@ -227,6 +228,8 @@ define([ if (this.positionOverPlot) { this.freeze(); this.marquee = { + startPixels: this.positionOverElement, + endPixels: this.positionOverElement, start: this.positionOverPlot, end: this.positionOverPlot, color: [1, 1, 1, 0.5] @@ -237,8 +240,14 @@ define([ }; MCTPlotController.prototype.endMarquee = function () { - if (this.marquee.start.x !== this.marquee.end.x && - this.marquee.start.y !== this.marquee.end.y) { + var startPixels = this.marquee.startPixels; + var endPixels = this.marquee.endPixels; + var marqueeDistance = Math.sqrt( + Math.pow(startPixels.x - endPixels.x, 2) + + Math.pow(startPixels.y - endPixels.y, 2) + ); + // Don't zoom if mouse moved less than 7.5 pixels. + if (marqueeDistance > 7.5) { this.$scope.xAxis.set('displayRange', { min: Math.min(this.marquee.start.x, this.marquee.end.x), max: Math.max(this.marquee.start.x, this.marquee.end.x) @@ -248,6 +257,10 @@ define([ max: Math.max(this.marquee.start.y, this.marquee.end.y) }); this.$scope.$emit('user:viewport:change:end'); + } else { + // A history entry is created by startMarquee, need to remove + // if marquee zoom doesn't occur. + this.back(); } this.$scope.rectangles = []; this.marquee = undefined;