mirror of
https://github.com/nasa/openmct.git
synced 2025-06-20 08:03:49 +00:00
[Info Bubble] Begin adding tests
Begin adding tests for info bubble, WTD-884.
This commit is contained in:
@ -23,6 +23,12 @@ define(
|
||||
mousePosition,
|
||||
scopeOff;
|
||||
|
||||
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 hideBubble() {
|
||||
// If a bubble is showing, dismiss it
|
||||
if (dismissBubble) {
|
||||
@ -33,6 +39,7 @@ define(
|
||||
// If a bubble will be shown on a timeout, cancel that
|
||||
if (pendingBubble) {
|
||||
$timeout.cancel(pendingBubble);
|
||||
element.off('mousemove', trackPosition);
|
||||
pendingBubble = undefined;
|
||||
}
|
||||
// Also clear mouse position so we don't have a ton of tiny
|
||||
@ -40,15 +47,12 @@ define(
|
||||
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);
|
||||
|
||||
// Also need to track position during hover
|
||||
element.on('mousemove', trackPosition);
|
||||
|
||||
// Show the bubble, after a suitable delay (if mouse has
|
||||
// left before this time is up, this will be canceled.)
|
||||
pendingBubble = $timeout(function () {
|
||||
@ -58,6 +62,7 @@ define(
|
||||
domainObject.useCapability('metadata'),
|
||||
mousePosition
|
||||
);
|
||||
element.off('mousemove', trackPosition);
|
||||
pendingBubble = undefined;
|
||||
}, DELAY);
|
||||
|
||||
@ -67,9 +72,6 @@ define(
|
||||
// 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);
|
||||
|
Reference in New Issue
Block a user