refactor(types): add NodePositionChange type

This commit is contained in:
moklick
2022-01-25 13:54:33 +01:00
parent 2a4dfce61c
commit 067d681485
4 changed files with 27 additions and 15 deletions
+2 -1
View File
@@ -13,6 +13,7 @@ import {
NodeDimensionChange,
EdgeSelectionChange,
NodeSelectionChange,
NodePositionChange,
} from '../types';
import { getHandleBounds } from '../components/Nodes/utils';
import { createSelectionChange, getSelectionChanges } from '../utils/changes';
@@ -96,7 +97,7 @@ const createStore = () =>
const { onNodesChange, nodeExtent, nodeInternals, hasDefaultNodes } = get();
if (hasDefaultNodes || onNodesChange) {
const changes: NodeDimensionChange[] = [];
const changes: NodePositionChange[] = [];
nodeInternals.forEach((node) => {
if (node.selected) {
+5 -5
View File
@@ -8,8 +8,8 @@ import {
Edge,
EdgeSelectionChange,
Node,
NodeDimensionChange,
NodeInternals,
NodePositionChange,
NodeSelectionChange,
ReactFlowState,
XYPosition,
@@ -103,7 +103,7 @@ export function isParentSelected(node: Node, nodeInternals: NodeInternals): bool
return isParentSelected(parentNode, nodeInternals);
}
type CreatePostiionChangeParams = {
type CreatePostionChangeParams = {
node: Node;
nodeExtent: CoordinateExtent;
nodeInternals: NodeInternals;
@@ -117,10 +117,10 @@ export function createPositionChange({
dragging,
nodeExtent,
nodeInternals,
}: CreatePostiionChangeParams): NodeDimensionChange {
const change: NodeDimensionChange = {
}: CreatePostionChangeParams): NodePositionChange {
const change: NodePositionChange = {
id: node.id,
type: 'dimensions',
type: 'position',
dragging: !!dragging,
};