[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:
Victor Woeltjen
2015-06-20 11:47:10 -07:00
parent bc7342b127
commit 8199d1d9d9
3 changed files with 36 additions and 9 deletions

View File

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