From 560c8612bd7721b3f03e1176e5dd7f2f25c0b5c2 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 8 Sep 2015 19:53:38 -0700 Subject: [PATCH] [Angular] Amend InfoGesture for compatibility Update the info gesture so that it does not schedule multiple bubbles to be shown when multiple events fire, for AngularJS 1.4.4 compatibility. --- .../inspect/src/gestures/InfoGesture.js | 29 ++++++++++++------- .../inspect/src/services/InfoService.js | 6 ++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/platform/commonUI/inspect/src/gestures/InfoGesture.js b/platform/commonUI/inspect/src/gestures/InfoGesture.js index 271857a592..3aa4b05634 100644 --- a/platform/commonUI/inspect/src/gestures/InfoGesture.js +++ b/platform/commonUI/inspect/src/gestures/InfoGesture.js @@ -57,7 +57,8 @@ define( // Also make sure we dismiss bubble if representation is destroyed // before the mouse actually leaves it - this.scopeOff = element.scope().$on('$destroy', this.hideBubbleCallback); + this.scopeOff = + element.scope().$on('$destroy', this.hideBubbleCallback); this.element = element; this.$timeout = $timeout; @@ -97,14 +98,7 @@ define( InfoGesture.prototype.showBubble = function (event) { var self = this; - this.trackPosition(event); - - // Also need to track position during hover - this.element.on('mousemove', this.trackPositionCallback); - - // Show the bubble, after a suitable delay (if mouse has - // left before this time is up, this will be canceled.) - this.pendingBubble = this.$timeout(function () { + function displayBubble() { self.dismissBubble = self.infoService.display( "info-table", self.domainObject.getModel().name, @@ -113,7 +107,22 @@ define( ); self.element.off('mousemove', self.trackPositionCallback); self.pendingBubble = undefined; - }, this.delay); + } + + this.trackPosition(event); + + // If we're already going to sho + if (this.pendingBubble) { + return; + } + + // Also need to track position during hover + this.element.on('mousemove', this.trackPositionCallback); + + // Show the bubble, after a suitable delay (if mouse has + // left before this time is up, this will be canceled.) + this.pendingBubble = this.pendingBubble || + this.$timeout(displayBubble, this.delay); this.element.on('mouseleave', this.hideBubbleCallback); }; diff --git a/platform/commonUI/inspect/src/services/InfoService.js b/platform/commonUI/inspect/src/services/InfoService.js index ef2b35411f..bc4afbb190 100644 --- a/platform/commonUI/inspect/src/services/InfoService.js +++ b/platform/commonUI/inspect/src/services/InfoService.js @@ -69,7 +69,7 @@ define( scope.bubbleModel = content; scope.bubbleTemplate = templateKey; scope.bubbleLayout = (goUp ? 'arw-btm' : 'arw-top') + ' ' + - (goLeft ? 'arw-right' : 'arw-left'); + (goLeft ? 'arw-right' : 'arw-left'); scope.bubbleTitle = title; // Create the context menu @@ -92,7 +92,9 @@ define( body.append(bubble); // Return a function to dismiss the bubble - return function () { bubble.remove(); }; + return function () { + bubble.remove(); + }; }; return InfoService;