Skip to content

Commit

Permalink
refactor(node): set unscaled size on mount
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Jul 16, 2019
1 parent b10d4ca commit 2cdf0eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/SimpleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class App extends PureComponent {
if (!this.graphInstance) {
return false;
}
console.log('graph changed', elements);
// console.log('graph changed', elements);
}

onFitView() {
Expand Down
6 changes: 4 additions & 2 deletions src/NodeRenderer/NodeTypes/wrapNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
}, []);

Expand Down

0 comments on commit 2cdf0eb

Please sign in to comment.