refactor(node): set unscaled size on mount
This commit is contained in:
@@ -38,7 +38,7 @@ class App extends PureComponent {
|
|||||||
if (!this.graphInstance) {
|
if (!this.graphInstance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
console.log('graph changed', elements);
|
// console.log('graph changed', elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
onFitView() {
|
onFitView() {
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ export default NodeComponent => (props) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const bounds = nodeElement.current.getBoundingClientRect();
|
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) {
|
if (__width !== unscaledWith || __height !== unscaledHeight) {
|
||||||
graphContext.dispatch(updateNodeData(id, { __width: bounds.width, __height: bounds.height }));
|
graphContext.dispatch(updateNodeData(id, { __width: unscaledWith, __height: unscaledHeight }));
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user