fix(fitview): handle child nodes closes #2223
This commit is contained in:
@@ -39,16 +39,15 @@ const initialNodes: Node[] = [
|
|||||||
{
|
{
|
||||||
id: '4b',
|
id: '4b',
|
||||||
data: { label: 'Node 4b' },
|
data: { label: 'Node 4b' },
|
||||||
position: { x: 150, y: 50 },
|
position: { x: 100, y: 60 },
|
||||||
className: 'light',
|
className: 'light',
|
||||||
style: { backgroundColor: 'rgba(50, 50, 255, 0.5)', height: 200, width: 300 },
|
style: { backgroundColor: 'rgba(50, 50, 255, 0.5)', height: 200, width: 300 },
|
||||||
parentNode: '4',
|
parentNode: '4',
|
||||||
expandParent: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '4b1',
|
id: '4b1',
|
||||||
data: { label: 'Node 4b1' },
|
data: { label: 'Node 4b1' },
|
||||||
position: { x: 20, y: 20 },
|
position: { x: 40, y: 20 },
|
||||||
className: 'light',
|
className: 'light',
|
||||||
parentNode: '4b',
|
parentNode: '4b',
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -105,7 +105,7 @@ export function fitView(get: GetState<ReactFlowState>, options: InternalFitViewO
|
|||||||
if ((options.initial && !fitViewOnInitDone && fitViewOnInit) || !options.initial) {
|
if ((options.initial && !fitViewOnInitDone && fitViewOnInit) || !options.initial) {
|
||||||
if (d3Zoom && d3Selection) {
|
if (d3Zoom && d3Selection) {
|
||||||
const nodes = Array.from(nodeInternals.values()).filter((n) =>
|
const nodes = Array.from(nodeInternals.values()).filter((n) =>
|
||||||
options.includeHiddenNodes ? !n.parentNode && n.width && n.height : !n.parentNode && !n.hidden
|
options.includeHiddenNodes ? n.width && n.height : !n.hidden
|
||||||
);
|
);
|
||||||
|
|
||||||
const nodesInitialized = nodes.every((n) => n.width && n.height);
|
const nodesInitialized = nodes.every((n) => n.width && n.height);
|
||||||
|
|||||||
Reference in New Issue
Block a user