mirror of
https://github.com/mathuo/dockview
synced 2025-02-02 14:35:46 +00:00
Merge pull request #36 from mathuo/35-dockview-fromjson-fix
feat: adjust fromJSON logic
This commit is contained in:
commit
39eb6a3e25
File diff suppressed because it is too large
Load Diff
@ -154,8 +154,7 @@ export abstract class BaseGrid<T extends IGridPanelView>
|
|||||||
|
|
||||||
this.element.appendChild(this.gridview.element);
|
this.element.appendChild(this.gridview.element);
|
||||||
|
|
||||||
// TODO for some reason this is required before anything will layout correctly
|
this.layout(0, 0, true); // set some elements height/widths
|
||||||
this.layout(0, 0, true);
|
|
||||||
|
|
||||||
this.addDisposables(
|
this.addDisposables(
|
||||||
this.gridview.onDidChange(() => {
|
this.gridview.onDidChange(() => {
|
||||||
|
@ -289,7 +289,8 @@ export class Gridview implements IDisposable {
|
|||||||
|
|
||||||
public deserialize(json: any, deserializer: IViewDeserializer) {
|
public deserialize(json: any, deserializer: IViewDeserializer) {
|
||||||
const orientation = json.orientation;
|
const orientation = json.orientation;
|
||||||
const height = json.height;
|
const height =
|
||||||
|
orientation === Orientation.VERTICAL ? json.height : json.width;
|
||||||
this._deserialize(
|
this._deserialize(
|
||||||
json.root as ISerializedBranchNode,
|
json.root as ISerializedBranchNode,
|
||||||
orientation,
|
orientation,
|
||||||
@ -308,7 +309,8 @@ export class Gridview implements IDisposable {
|
|||||||
root,
|
root,
|
||||||
orientation,
|
orientation,
|
||||||
deserializer,
|
deserializer,
|
||||||
orthogonalSize
|
orthogonalSize,
|
||||||
|
true
|
||||||
) as BranchNode;
|
) as BranchNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +318,8 @@ export class Gridview implements IDisposable {
|
|||||||
node: ISerializedNode,
|
node: ISerializedNode,
|
||||||
orientation: Orientation,
|
orientation: Orientation,
|
||||||
deserializer: IViewDeserializer,
|
deserializer: IViewDeserializer,
|
||||||
orthogonalSize: number
|
orthogonalSize: number,
|
||||||
|
isRoot = false
|
||||||
): Node {
|
): Node {
|
||||||
let result: Node;
|
let result: Node;
|
||||||
if (node.type === 'branch') {
|
if (node.type === 'branch') {
|
||||||
@ -333,12 +336,14 @@ export class Gridview implements IDisposable {
|
|||||||
} as INodeDescriptor;
|
} as INodeDescriptor;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// HORIZONTAL => height=orthogonalsize width=size
|
||||||
|
// VERTICAL => height=size width=orthogonalsize
|
||||||
result = new BranchNode(
|
result = new BranchNode(
|
||||||
orientation,
|
orientation,
|
||||||
this.proportionalLayout,
|
this.proportionalLayout,
|
||||||
this.styles,
|
this.styles,
|
||||||
node.size,
|
isRoot ? orthogonalSize : node.size,
|
||||||
orthogonalSize,
|
isRoot ? node.size : orthogonalSize,
|
||||||
children
|
children
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user