Skip to content

Commit

Permalink
refactor(node): only update size when changed
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Oct 25, 2019
1 parent caebec6 commit ecbc294
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ const storeModel: StoreModel = {
updateNodeDimensions: action((state, { id, nodeElement }) => {
const bounds = nodeElement.getBoundingClientRect();
const dimensions = getDimensions(nodeElement);
const matchingNode = state.nodes.find(n => n.id === id);

// only update when size change
if (
!matchingNode ||
(matchingNode.__rg.width === dimensions.width && matchingNode.__rg.height === dimensions.height)
) {
return;
}

const handleBounds = {
source: getHandleBounds('.source', nodeElement, bounds, state.transform[2]),
target: getHandleBounds('.target', nodeElement, bounds, state.transform[2]),
Expand Down

0 comments on commit ecbc294

Please sign in to comment.