mirror of
https://github.com/nasa/openmct.git
synced 2025-01-01 19:06:40 +00:00
[Plot] Use mct-drag from plot
Use mct-drag from plot such that we are able to handle mouse events which leave the plot area for marquee zoom and pan. WTD-1273.
This commit is contained in:
parent
bc7342b127
commit
8199d1d9d9
@ -57,13 +57,17 @@ define(
|
|||||||
// mouse may leave this element during the drag.
|
// mouse may leave this element during the drag.
|
||||||
var body = $document.find('body'),
|
var body = $document.find('body'),
|
||||||
initialPosition,
|
initialPosition,
|
||||||
|
$event,
|
||||||
delta;
|
delta;
|
||||||
|
|
||||||
// Utility function to cause evaluation of mctDrag,
|
// Utility function to cause evaluation of mctDrag,
|
||||||
// mctDragUp, etc
|
// mctDragUp, etc
|
||||||
function fireListener(name) {
|
function fireListener(name) {
|
||||||
// Evaluate the expression, with current delta
|
// Evaluate the expression, with current delta
|
||||||
scope.$eval(attrs[name], { delta: delta });
|
scope.$eval(attrs[name], {
|
||||||
|
delta: delta,
|
||||||
|
$event: $event
|
||||||
|
});
|
||||||
|
|
||||||
// Trigger prompt digestion
|
// Trigger prompt digestion
|
||||||
scope.$apply();
|
scope.$apply();
|
||||||
@ -82,6 +86,9 @@ define(
|
|||||||
delta = currentPosition.map(function (v, i) {
|
delta = currentPosition.map(function (v, i) {
|
||||||
return v - initialPosition[i];
|
return v - initialPosition[i];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Also track the plain event for firing listeners
|
||||||
|
$event = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called during a drag, on mousemove
|
// Called during a drag, on mousemove
|
||||||
@ -106,7 +113,7 @@ define(
|
|||||||
|
|
||||||
fireListener("mctDragUp");
|
fireListener("mctDragUp");
|
||||||
|
|
||||||
// Clear out start-of-drag position
|
// Clear out start-of-drag position, target
|
||||||
initialPosition = undefined;
|
initialPosition = undefined;
|
||||||
|
|
||||||
// Don't show selection highlights, etc
|
// Don't show selection highlights, etc
|
||||||
@ -131,6 +138,7 @@ define(
|
|||||||
|
|
||||||
// Don't show selection highlights, etc
|
// Don't show selection highlights, etc
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,4 +156,4 @@ define(
|
|||||||
|
|
||||||
return MCTDrag;
|
return MCTDrag;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -82,8 +82,9 @@
|
|||||||
|
|
||||||
<mct-chart draw="subplot.getDrawingObject()"
|
<mct-chart draw="subplot.getDrawingObject()"
|
||||||
ng-mousemove="subplot.hover($event)"
|
ng-mousemove="subplot.hover($event)"
|
||||||
ng-mousedown="subplot.startMarquee($event)"
|
mct-drag="subplot.continueDrag($event)"
|
||||||
ng-mouseup="subplot.endMarquee($event); plot.update()">
|
mct-drag-down="subplot.startDrag($event)"
|
||||||
|
mct-drag-up="subplot.endDrag($event); plot.update()">
|
||||||
</mct-chart>
|
</mct-chart>
|
||||||
|
|
||||||
<!-- TODO: Move into correct position; make part of group; infer from set of actions -->
|
<!-- TODO: Move into correct position; make part of group; infer from set of actions -->
|
||||||
|
@ -58,6 +58,7 @@ define(
|
|||||||
marqueeStart,
|
marqueeStart,
|
||||||
panStart,
|
panStart,
|
||||||
panStartBounds,
|
panStartBounds,
|
||||||
|
subPlotBounds,
|
||||||
hoverCoordinates,
|
hoverCoordinates,
|
||||||
isHovering = false;
|
isHovering = false;
|
||||||
|
|
||||||
@ -90,8 +91,7 @@ define(
|
|||||||
// pixel coordinates in the canvas area) from a mouse
|
// pixel coordinates in the canvas area) from a mouse
|
||||||
// event object.
|
// event object.
|
||||||
function toMousePosition($event) {
|
function toMousePosition($event) {
|
||||||
var target = $event.target,
|
var bounds = subPlotBounds;
|
||||||
bounds = target.getBoundingClientRect();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x: $event.clientX - bounds.left,
|
x: $event.clientX - bounds.left,
|
||||||
@ -262,6 +262,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
hover: function ($event) {
|
hover: function ($event) {
|
||||||
isHovering = true;
|
isHovering = true;
|
||||||
|
subPlotBounds = $event.target.getBoundingClientRect();
|
||||||
mousePosition = toMousePosition($event);
|
mousePosition = toMousePosition($event);
|
||||||
updateHoverCoordinates();
|
updateHoverCoordinates();
|
||||||
if (marqueeStart) {
|
if (marqueeStart) {
|
||||||
@ -273,11 +274,27 @@ define(
|
|||||||
updateTicks();
|
updateTicks();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Continue a previously-start pan or zoom gesture.
|
||||||
|
* @param $event the mouse event
|
||||||
|
*/
|
||||||
|
continueDrag: function ($event) {
|
||||||
|
mousePosition = toMousePosition($event);
|
||||||
|
if (marqueeStart) {
|
||||||
|
updateMarqueeBox();
|
||||||
|
}
|
||||||
|
if (panStart) {
|
||||||
|
updatePan();
|
||||||
|
updateDrawingBounds();
|
||||||
|
updateTicks();
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Initiate a marquee zoom action.
|
* Initiate a marquee zoom action.
|
||||||
* @param $event the mouse event
|
* @param $event the mouse event
|
||||||
*/
|
*/
|
||||||
startMarquee: function ($event) {
|
startDrag: function ($event) {
|
||||||
|
subPlotBounds = $event.target.getBoundingClientRect();
|
||||||
mousePosition = toMousePosition($event);
|
mousePosition = toMousePosition($event);
|
||||||
if (event.altKey) {
|
if (event.altKey) {
|
||||||
// Start panning
|
// Start panning
|
||||||
@ -301,8 +318,9 @@ define(
|
|||||||
* Complete a marquee zoom action.
|
* Complete a marquee zoom action.
|
||||||
* @param $event the mouse event
|
* @param $event the mouse event
|
||||||
*/
|
*/
|
||||||
endMarquee: function ($event) {
|
endDrag: function ($event) {
|
||||||
mousePosition = toMousePosition($event);
|
mousePosition = toMousePosition($event);
|
||||||
|
subPlotBounds = undefined;
|
||||||
if (marqueeStart) {
|
if (marqueeStart) {
|
||||||
marqueeZoom(marqueeStart, mousePosition);
|
marqueeZoom(marqueeStart, mousePosition);
|
||||||
marqueeStart = undefined;
|
marqueeStart = undefined;
|
||||||
|
Loading…
Reference in New Issue
Block a user