mirror of
https://github.com/nasa/openmct.git
synced 2025-06-13 04:38:15 +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:
@ -58,6 +58,7 @@ define(
|
||||
marqueeStart,
|
||||
panStart,
|
||||
panStartBounds,
|
||||
subPlotBounds,
|
||||
hoverCoordinates,
|
||||
isHovering = false;
|
||||
|
||||
@ -90,8 +91,7 @@ define(
|
||||
// pixel coordinates in the canvas area) from a mouse
|
||||
// event object.
|
||||
function toMousePosition($event) {
|
||||
var target = $event.target,
|
||||
bounds = target.getBoundingClientRect();
|
||||
var bounds = subPlotBounds;
|
||||
|
||||
return {
|
||||
x: $event.clientX - bounds.left,
|
||||
@ -262,6 +262,7 @@ define(
|
||||
*/
|
||||
hover: function ($event) {
|
||||
isHovering = true;
|
||||
subPlotBounds = $event.target.getBoundingClientRect();
|
||||
mousePosition = toMousePosition($event);
|
||||
updateHoverCoordinates();
|
||||
if (marqueeStart) {
|
||||
@ -273,11 +274,27 @@ define(
|
||||
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.
|
||||
* @param $event the mouse event
|
||||
*/
|
||||
startMarquee: function ($event) {
|
||||
startDrag: function ($event) {
|
||||
subPlotBounds = $event.target.getBoundingClientRect();
|
||||
mousePosition = toMousePosition($event);
|
||||
if (event.altKey) {
|
||||
// Start panning
|
||||
@ -301,8 +318,9 @@ define(
|
||||
* Complete a marquee zoom action.
|
||||
* @param $event the mouse event
|
||||
*/
|
||||
endMarquee: function ($event) {
|
||||
endDrag: function ($event) {
|
||||
mousePosition = toMousePosition($event);
|
||||
subPlotBounds = undefined;
|
||||
if (marqueeStart) {
|
||||
marqueeZoom(marqueeStart, mousePosition);
|
||||
marqueeStart = undefined;
|
||||
|
Reference in New Issue
Block a user