diff --git a/src/js/Node.js b/src/js/Node.js index 38c57a9..5722e10 100644 --- a/src/js/Node.js +++ b/src/js/Node.js @@ -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" diff --git a/src/js/treemode.js b/src/js/treemode.js index 8b10e1c..fb8db82 100644 --- a/src/js/treemode.js +++ b/src/js/treemode.js @@ -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;