diff --git a/example/SimpleGraph.js b/example/SimpleGraph.js index f085b673..bc4925ed 100644 --- a/example/SimpleGraph.js +++ b/example/SimpleGraph.js @@ -38,7 +38,7 @@ class App extends PureComponent { if (!this.graphInstance) { return false; } - console.log('graph changed', elements); + // console.log('graph changed', elements); } onFitView() { diff --git a/src/NodeRenderer/NodeTypes/wrapNode.js b/src/NodeRenderer/NodeTypes/wrapNode.js index 034a6db5..ff40a911 100644 --- a/src/NodeRenderer/NodeTypes/wrapNode.js +++ b/src/NodeRenderer/NodeTypes/wrapNode.js @@ -13,9 +13,11 @@ export default NodeComponent => (props) => { useEffect(() => { const bounds = nodeElement.current.getBoundingClientRect(); + const unscaledWith = Math.round(bounds.width * (1 / k)); + const unscaledHeight = Math.round(bounds.height * (1 / k)); - if (__width !== bounds.width || __height !== bounds.height) { - graphContext.dispatch(updateNodeData(id, { __width: bounds.width, __height: bounds.height })); + if (__width !== unscaledWith || __height !== unscaledHeight) { + graphContext.dispatch(updateNodeData(id, { __width: unscaledWith, __height: unscaledHeight })); } }, []);