Fixed jumping of selected nodes when dragging the lower down nodes

This commit is contained in:
jos 2015-12-30 21:39:49 +01:00
parent e90248c0d0
commit e372441542
2 changed files with 28 additions and 5 deletions

View File

@ -1221,9 +1221,14 @@ Node.onDragStart = function (nodes, event) {
var firstNode = nodes[0];
var lastNode = nodes[nodes.length - 1];
var draggedNode = Node.getNodeFromTarget(event.target);
var beforeNode = lastNode._nextSibling();
var editor = firstNode.editor;
// in case of multiple selected nodes, offsetY prevents the selection from
// jumping when you start dragging one of the lower down nodes in the selection
var offsetY = util.getAbsoluteTop(draggedNode.dom.tr) - util.getAbsoluteTop(firstNode.dom.tr);
if (!editor.mousemove) {
editor.mousemove = util.addEventListener(window, 'mousemove', function (event) {
Node.onDrag(nodes, event);
@ -1242,6 +1247,7 @@ Node.onDragStart = function (nodes, event) {
oldSelection: editor.getSelection(),
oldBeforeNode: beforeNode,
mouseX: event.pageX,
offsetY: offsetY,
level: firstNode.getLevel()
};
document.body.style.cursor = 'move';
@ -1263,10 +1269,9 @@ Node.onDrag = function (nodes, event) {
}
// TODO: this method has grown too large. Split it in a number of methods
var mouseY = event.pageY;
var mouseX = event.pageX;
var editor = nodes[0].editor;
var mouseY = event.pageY - editor.drag.offsetY;
var mouseX = event.pageX;
var trThis, trPrev, trNext, trFirst, trLast, trRoot;
var nodePrev, nodeNext;
var topThis, topPrev, topFirst, heightThis, bottomNext, heightNext;
@ -1368,8 +1373,7 @@ Node.onDrag = function (nodes, event) {
}
else if (nodePrev instanceof AppendNode) {
var childs = nodePrev.parent.childs;
if (childs.length > nodes.length ||
(childs.length == nodes.length && childs[nodes.length - 1] != lastNode)) {
if (childs.length != nodes.length || childs[nodes.length - 1] != lastNode) {
// non-visible append node of a list of childs
// consisting of not only this node (else the
// append node will change into a visible "empty"

View File

@ -681,6 +681,11 @@ treemode._onEvent = function (event) {
}
};
/**
* Start multi selection of nodes by dragging the mouse
* @param event
* @private
*/
treemode._onMultiSelectStart = function (event) {
var node = Node.getNodeFromTarget(event.target);
@ -704,6 +709,11 @@ treemode._onMultiSelectStart = function (event) {
};
/**
* Multiselect nodes by dragging
* @param event
* @private
*/
treemode._onMultiSelect = function (event) {
event.preventDefault();
@ -729,7 +739,16 @@ treemode._onMultiSelect = function (event) {
}
};
/**
* End of multiselect nodes by dragging
* @param event
* @private
*/
treemode._onMultiSelectEnd = function (event) {
if (this.multiselection.end) {
this.multiselection.end.dom.menu.focus();
}
this.multiselection.start = null;
this.multiselection.end = null;