mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
fix(container): container render bounds delay
This commit is contained in:
parent
d8ce164255
commit
970fd09ec4
@ -21,13 +21,10 @@ export const ContainerNodeContainer: FC<IContainerNodeContainer> = ({ children }
|
||||
const [height, setHeight] = useState(size.height);
|
||||
|
||||
const updatePorts = () => {
|
||||
requestAnimationFrame(() => {
|
||||
const portsData = node.getData<WorkflowNodePortsData>(WorkflowNodePortsData);
|
||||
portsData.updateDynamicPorts();
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const updateSize = () => {
|
||||
// 无子节点时
|
||||
if (node.blocks.length === 0) {
|
||||
@ -36,20 +33,22 @@ export const ContainerNodeContainer: FC<IContainerNodeContainer> = ({ children }
|
||||
return;
|
||||
}
|
||||
// 存在子节点时,只监听宽高变化
|
||||
if (width !== transform.bounds.width) {
|
||||
setWidth(transform.bounds.width);
|
||||
}
|
||||
if (height !== transform.bounds.height) {
|
||||
setHeight(transform.bounds.height);
|
||||
}
|
||||
};
|
||||
updateSize();
|
||||
|
||||
useEffect(() => {
|
||||
const dispose = transform.onDataChange(() => {
|
||||
updateSize();
|
||||
updatePorts();
|
||||
});
|
||||
return () => dispose.dispose();
|
||||
}, [transform]);
|
||||
}, [transform, width, height]);
|
||||
|
||||
useEffect(() => {
|
||||
// 初始化触发一次
|
||||
updateSize();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ContainerNodeContainerStyle
|
||||
|
||||
@ -102,6 +102,7 @@ export class NodeIntoContainerService {
|
||||
x: parentTransform.position.x + nodeJSON.meta!.position!.x,
|
||||
y: parentTransform.position.y + nodeJSON.meta!.position!.y,
|
||||
});
|
||||
parentTransform.fireChange();
|
||||
await this.nextFrame();
|
||||
parentTransform.fireChange();
|
||||
this.emitter.fire({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user