refactor(node): set unscaled size on mount

This commit is contained in:
moklick
2019-07-16 13:16:30 +02:00
parent b10d4ca5e5
commit 2cdf0eb179
2 changed files with 5 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ class App extends PureComponent {
if (!this.graphInstance) {
return false;
}
console.log('graph changed', elements);
// console.log('graph changed', elements);
}
onFitView() {

View File

@@ -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 }));
}
}, []);