Skip to content

Commit 8a221f1

Browse files
committed
multi move
1 parent fb8dfff commit 8a221f1

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

services/static-webserver/client/source/class/osparc/workbench/NodeUI.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,10 +709,14 @@ qx.Class.define("osparc.workbench.NodeUI", {
709709
};
710710
},
711711

712+
moveNodeTo: function(pos) {
713+
this.moveTo(pos.x, pos.y);
714+
},
715+
712716
setPosition: function(pos) {
713717
const node = this.getNode();
714718
node.setPosition(pos);
715-
this.moveTo(node.getPosition().x, node.getPosition().y);
719+
this.moveNodeTo(pos);
716720
},
717721

718722
snapToGrid: function() {
@@ -724,11 +728,10 @@ qx.Class.define("osparc.workbench.NodeUI", {
724728
const snapGrid = 20;
725729
const snapX = Math.round(x/snapGrid)*snapGrid;
726730
const snapY = Math.round(y/snapGrid)*snapGrid;
727-
node.setPosition({
731+
this.setPosition({
728732
x: snapX,
729733
y: snapY
730734
});
731-
this.moveTo(node.getPosition().x, node.getPosition().y);
732735
},
733736

734737
__applyThumbnail: function(thumbnailSrc) {

services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
443443
__itemMoving: function(itemId, xDiff, yDiff) {
444444
this.getSelectedNodeUIs().forEach(selectedNodeUI => {
445445
if (itemId !== selectedNodeUI.getNodeId()) {
446-
selectedNodeUI.setPosition({
446+
// do not touch the position, just move the node, this will happen in __itemStoppedMoving
447+
selectedNodeUI.moveNodeTo({
447448
x: selectedNodeUI.initPos.x + xDiff,
448449
y: selectedNodeUI.initPos.y + yDiff
449450
});
@@ -464,10 +465,24 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
464465
this.getSelectedNodeUIs().forEach(selectedNodeUI => delete selectedNodeUI["initPos"]);
465466
this.getSelectedAnnotations().forEach(selectedAnnotation => delete selectedAnnotation["initPos"]);
466467

467-
if (nodeUI && osparc.Preferences.getInstance().isSnapNodeToGrid()) {
468-
this.getSelectedNodeUIs().forEach(selectedNodeUI => selectedNodeUI.snapToGrid());
469-
// make sure nodeUI is moved, then update edges
470-
setTimeout(() => this.__updateNodeUIPos(nodeUI), 10);
468+
// the moving item could be an annotation, so we need to check if it is a nodeUI
469+
if (nodeUI) {
470+
this.getSelectedNodeUIs().forEach(selectedNodeUI => {
471+
if (nodeUI !== selectedNodeUI) {
472+
// now set the position
473+
const layoutProps = selectedNodeUI.getLayoutProperties();
474+
selectedNodeUI.setPosition({
475+
x: layoutProps.left,
476+
y: layoutProps.top,
477+
});
478+
}
479+
});
480+
481+
if (osparc.Preferences.getInstance().isSnapNodeToGrid()) {
482+
this.getSelectedNodeUIs().forEach(selectedNodeUI => selectedNodeUI.snapToGrid());
483+
// make sure nodeUI is moved, then update edges
484+
setTimeout(() => this.__updateNodeUIPos(nodeUI), 10);
485+
}
471486
}
472487

473488
this.__updateWorkbenchBounds();

0 commit comments

Comments
 (0)