diff --git a/platform/commonUI/inspect/res/bubble.html b/platform/commonUI/inspect/res/bubble.html index 07395447b1..5090eb1199 100644 --- a/platform/commonUI/inspect/res/bubble.html +++ b/platform/commonUI/inspect/res/bubble.html @@ -1,4 +1,4 @@ -
+
diff --git a/platform/commonUI/inspect/src/gestures/InfoGesture.js b/platform/commonUI/inspect/src/gestures/InfoGesture.js index a1a83b92d8..584d45d40c 100644 --- a/platform/commonUI/inspect/src/gestures/InfoGesture.js +++ b/platform/commonUI/inspect/src/gestures/InfoGesture.js @@ -8,28 +8,37 @@ define( function InfoGesture($timeout, infoService, DELAY, element, domainObject) { var dismissBubble, pendingBubble, - mousePosition; + mousePosition, + scopeOff; function hideBubble() { + // If a bubble is showing, dismiss it if (dismissBubble) { dismissBubble(); element.off('mouseleave', hideBubble); dismissBubble = undefined; } + // If a bubble will be shown on a timeout, cancel that if (pendingBubble) { $timeout.cancel(pendingBubble); pendingBubble = undefined; } + // Also clear mouse position so we don't have a ton of tiny + // arrays allocated while user mouses over things mousePosition = undefined; } function trackPosition(event) { + // Record mouse position, so bubble can be shown at latest + // mouse position (not just where the mouse entered) mousePosition = [ event.clientX, event.clientY ]; } function showBubble(event) { trackPosition(event); + // Show the bubble, after a suitable delay (if mouse has + // left before this time is up, this will be canceled.) pendingBubble = $timeout(function () { dismissBubble = infoService.display( "info-table", @@ -45,13 +54,23 @@ define( element.on('mouseleave', hideBubble); } - element.on('mousemove', trackPosition); + // Show bubble (on a timeout) on mouse over element.on('mouseenter', showBubble); + // Also need to track position during hover + element.on('mousemove', trackPosition); + + // Also make sure we dismiss bubble if representation is destroyed + // before the mouse actually leaves it + scopeOff = element.scope().$on('$destroy', hideBubble); + return { destroy: function () { + // Dismiss any active bubble... hideBubble(); + // ...and detach listeners element.off('mouseenter', showBubble); + scopeOff(); } }; } diff --git a/platform/commonUI/inspect/src/services/InfoService.js b/platform/commonUI/inspect/src/services/InfoService.js index ccba01b711..f071bacad5 100644 --- a/platform/commonUI/inspect/src/services/InfoService.js +++ b/platform/commonUI/inspect/src/services/InfoService.js @@ -40,12 +40,12 @@ define( // Position the bubble bubble.css('position', 'absolute'); if (goLeft) { - bubble.css('right', (winDim[0] - position[0] + OFFSET[0]) + 'px'); + bubble.css('right', (winDim[0] - position[0] - OFFSET[0]) + 'px'); } else { bubble.css('left', position[0] - OFFSET[0] + 'px'); } if (goUp) { - bubble.css('bottom', (winDim[1] - position[1] + OFFSET[1]) + 'px'); + bubble.css('bottom', (winDim[1] - position[1] - OFFSET[1]) + 'px'); } else { bubble.css('top', position[1] - OFFSET[1] + 'px'); }