You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// the mouse is outside the current parent, the nodes can't be dragged out
913
979
// console.log("Cannot drop outside parent scope");
980
+
// but position should also be updated
981
+
nodes.forEach((node)=>{
982
+
setPodPosition({
983
+
id: node.id,
984
+
x: node.position.x,
985
+
y: node.position.y,
986
+
dirty: true,
987
+
});
988
+
});
914
989
return;
915
990
}
916
991
}
917
992
}
918
993
994
+
// no target scope, or the target scope is the same as the current parent
995
+
if(!scope||scope.id===commonParent){
996
+
// only update position and exit, avoid updating parentNode
997
+
nodes.forEach((node)=>{
998
+
setPodPosition({
999
+
id: node.id,
1000
+
x: node.position.x,
1001
+
y: node.position.y,
1002
+
dirty: true,
1003
+
});
1004
+
});
1005
+
return;
1006
+
}
1007
+
919
1008
// check if this position is inside parent scope
920
1009
nodes.forEach((node)=>{
921
1010
letabsX=node.position.x;
922
1011
letabsY=node.position.y;
923
1012
924
-
if(scope){
925
-
console.log("dropped into scope:",scope);
926
-
// compute the actual position
927
-
let[dx,dy]=getAbsPos({node: scope, nodesMap });
928
-
absX=node.positionAbsolute!.x-dx;
929
-
absY=node.positionAbsolute!.y-dy;
930
-
// auto-align the node to, keep it bound in the scope
931
-
// FIXME: it assumes the scope must be larger than the node
932
-
933
-
absX=Math.max(absX,0);
934
-
absX=Math.min(absX,scope.width!-node.width!);
935
-
absY=Math.max(absY,0);
936
-
absY=Math.min(absY,scope.height!-node.height!);
937
-
}
938
-
setPodPosition({
1013
+
console.log("dropped into scope:",scope);
1014
+
// compute the actual position
1015
+
let[dx,dy]=getAbsPos({node: scope, nodesMap });
1016
+
absX=node.positionAbsolute!.x-dx;
1017
+
absY=node.positionAbsolute!.y-dy;
1018
+
// auto-align the node to, keep it bound in the scope
1019
+
// FIXME: it assumes the scope must be larger than the node
1020
+
1021
+
absX=Math.max(absX,0);
1022
+
absX=Math.min(absX,scope.width!-node.width!);
1023
+
absY=Math.max(absY,0);
1024
+
absY=Math.min(absY,scope.height!-node.height!);
1025
+
1026
+
setPodParent({
939
1027
id: node.id,
940
-
x: absX,
941
-
y: absY,
1028
+
parent: scope.id,
1029
+
dirty: true,
942
1030
});
943
1031
944
-
// check if this position is inside parent scope
945
-
if(scope&&scope.id!==commonParent){
946
-
// FIXME: to enable collaborative editing, consider how to sync dropping scope immediately. consider useEffect in each node when data.parent or parent changes.
0 commit comments