fix(nodes): always drag draggable node even if not selected
This commit is contained in:
@@ -124,6 +124,7 @@ export default (NodeComponent: ComponentType<NodeComponentProps>) => {
|
|||||||
const onDrag = useCallback(
|
const onDrag = useCallback(
|
||||||
(_, data) => {
|
(_, data) => {
|
||||||
updateNodePosDiff({
|
updateNodePosDiff({
|
||||||
|
id,
|
||||||
diff: {
|
diff: {
|
||||||
x: data.deltaX,
|
x: data.deltaX,
|
||||||
y: data.deltaY,
|
y: data.deltaY,
|
||||||
@@ -148,6 +149,7 @@ export default (NodeComponent: ComponentType<NodeComponentProps>) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateNodePosDiff({
|
updateNodePosDiff({
|
||||||
|
id: node.id,
|
||||||
isDragging: false,
|
isDragging: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -263,9 +263,9 @@ export const storeModel: StoreModel = {
|
|||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|
||||||
updateNodePosDiff: action((state, { diff = null, isDragging = true }) => {
|
updateNodePosDiff: action((state, { id = null, diff = null, isDragging = true }) => {
|
||||||
state.elements.forEach((n) => {
|
state.elements.forEach((n) => {
|
||||||
if (isNode(n) && state.selectedElements?.find((sNode) => sNode.id === n.id)) {
|
if (isNode(n) && (id === n.id || state.selectedElements?.find((sNode) => sNode.id === n.id))) {
|
||||||
if (diff) {
|
if (diff) {
|
||||||
n.__rf.position = {
|
n.__rf.position = {
|
||||||
x: n.__rf.position.x + diff.x,
|
x: n.__rf.position.x + diff.x,
|
||||||
|
|||||||
@@ -308,6 +308,7 @@ export type NodePosUpdate = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type NodeDiffUpdate = {
|
export type NodeDiffUpdate = {
|
||||||
|
id?: ElementId;
|
||||||
diff?: XYPosition;
|
diff?: XYPosition;
|
||||||
isDragging?: boolean;
|
isDragging?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user