Merge branch 'main' into feat/packages
This commit is contained in:
@@ -119,8 +119,9 @@ function useDrag({
|
||||
lastPos.current.x = (lastPos.current.x ?? 0) - xMovement / transform[2];
|
||||
lastPos.current.y = (lastPos.current.y ?? 0) - yMovement / transform[2];
|
||||
|
||||
updateNodes(lastPos.current as XYPosition);
|
||||
panBy({ x: xMovement, y: yMovement });
|
||||
if (panBy({ x: xMovement, y: yMovement })) {
|
||||
updateNodes(lastPos.current as XYPosition);
|
||||
}
|
||||
}
|
||||
autoPanId.current = requestAnimationFrame(autoPan);
|
||||
};
|
||||
|
||||
@@ -6,13 +6,20 @@ import { useStoreApi } from '../hooks/useStore';
|
||||
function useUpdateNodeInternals(): UpdateNodeInternals {
|
||||
const store = useStoreApi();
|
||||
|
||||
return useCallback<UpdateNodeInternals>((id: string) => {
|
||||
return useCallback<UpdateNodeInternals>((id: string | string[]) => {
|
||||
const { domNode, updateNodeDimensions } = store.getState();
|
||||
const nodeElement = domNode?.querySelector(`.react-flow__node[data-id="${id}"]`) as HTMLDivElement;
|
||||
|
||||
if (nodeElement) {
|
||||
requestAnimationFrame(() => updateNodeDimensions([{ id, nodeElement, forceUpdate: true }]));
|
||||
}
|
||||
const updateIds = Array.isArray(id) ? id : [id];
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
updateIds.forEach((updateId) => {
|
||||
const nodeElement = domNode?.querySelector(`.react-flow__node[data-id="${updateId}"]`) as HTMLDivElement;
|
||||
|
||||
if (nodeElement) {
|
||||
updateNodeDimensions([{ id: updateId, nodeElement, forceUpdate: true }]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, []);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user