From ecbc2944e673a64682850b2e8bf14de189418bd1 Mon Sep 17 00:00:00 2001 From: moklick Date: Fri, 25 Oct 2019 15:07:28 +0200 Subject: [PATCH] refactor(node): only update size when changed --- src/store/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/store/index.ts b/src/store/index.ts index 19ed9dda..05eafdf3 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -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]),