[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.
This commit is contained in:
Victor Woeltjen 2015-09-08 19:53:38 -07:00
parent 6a917f5393
commit 560c8612bd
2 changed files with 23 additions and 12 deletions

View File

@ -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);
};

View File

@ -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;