[Layout] Fix errors in mct-drag

Properly reset the initial drag position tracked by the
mct-drag position so that multiple drags upon the same
element are correctly offset from an initial position.
Also, preventDefault from events to avoid selection
highlights during drag.

Supports editing Layout objects, for WTD-535.
This commit is contained in:
Victor Woeltjen 2014-12-05 08:50:45 -08:00
parent 479aaa09fb
commit b941557b41

View File

@ -28,6 +28,10 @@ define(
function continueDrag(event) {
updatePosition(event);
fireListener("mctDrag");
// Don't show selection highlights, etc
event.preventDefault();
return false;
}
function endDrag(event) {
@ -37,14 +41,27 @@ define(
continueDrag(event);
fireListener("mctDragUp");
// Clear out start-of-drag position
initialPosition = undefined;
// Don't show selection highlights, etc
event.preventDefault();
return false;
}
function startDrag(event) {
body.on("mouseup", endDrag);
body.on("mousemove", continueDrag);
updatePosition(event);
fireListener("mctDragDown");
fireListener("mctDrag");
// Don't show selection highlights, etc
event.preventDefault();
return false;
}
element.on("mousedown", startDrag);