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
// auto-align the node to, keep it bound in the scope
936
-
// FIXME: it assumes the scope must be larger than the node
937
923
938
-
absX=Math.max(absX,0);
939
-
absX=Math.min(absX,scope.width!-node.width!);
940
-
absY=Math.max(absY,0);
941
-
absY=Math.min(absY,scope.height!-node.height!);
942
-
943
-
// FIXME: to enable collaborative editing, consider how to sync dropping scope immediately. consider useEffect in each node when data.parent or parent changes.
944
-
setPodParent({
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({
945
939
id: node.id,
946
-
parent: scope.id,
940
+
x: absX,
941
+
y: absY,
947
942
});
948
943
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.
947
+
setPodParent({
948
+
id: node.id,
949
+
parent: scope.id,
950
+
});
951
+
}
952
+
949
953
constcurrentNode=nodesMap.get(node.id);
950
954
if(currentNode){
951
955
if(scope){
@@ -960,14 +964,7 @@ export function Canvas() {
960
964
});
961
965
},
962
966
// We need to monitor nodes, so that getScopeAt can have all the nodes.
0 commit comments