提交 0644a056 编写于 作者: J Joao Moreno

grid fix removeView

上级 d72c0799
......@@ -333,16 +333,18 @@ export class GridView implements IGrid, IDisposable {
const [, parentIndex] = tail(rest);
const sibling = parent.children[0];
if (!(sibling instanceof LeafNode)) {
throw new Error('Invalid grid state');
}
parent.removeChild(0);
grandParent.removeChild(parentIndex);
const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
grandParent.addChild(newSibling, sibling.orthogonalSize, parentIndex);
if (sibling instanceof BranchNode) {
for (let i = 0; i < sibling.children.length; i++) {
const child = sibling.children[i];
grandParent.addChild(child, child.size, parentIndex + i);
}
} else {
const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
grandParent.addChild(newSibling, sibling.orthogonalSize, parentIndex);
}
return node.view;
}
......
......@@ -98,6 +98,10 @@
grid.splitView(view1, Direction.Right, view4, 200);
debug(grid);
console.log('-------');
const view5 = createView();
grid.splitView(view1, Direction.Down, view5, 200);
debug(grid);
console.log('-------');
// const view5 = createView();
// grid.splitView(view2, Direction.Down, view5, 200);
// debug(grid);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册