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);
|
||||
|
||||
// TODO for some reason this is required before anything will layout correctly
|
||||
this.layout(0, 0, true);
|
||||
this.layout(0, 0, true); // set some elements height/widths
|
||||
|
||||
this.addDisposables(
|
||||
this.gridview.onDidChange(() => {
|
||||
|
@ -289,7 +289,8 @@ export class Gridview implements IDisposable {
|
||||
|
||||
public deserialize(json: any, deserializer: IViewDeserializer) {
|
||||
const orientation = json.orientation;
|
||||
const height = json.height;
|
||||
const height =
|
||||
orientation === Orientation.VERTICAL ? json.height : json.width;
|
||||
this._deserialize(
|
||||
json.root as ISerializedBranchNode,
|
||||
orientation,
|
||||
@ -308,7 +309,8 @@ export class Gridview implements IDisposable {
|
||||
root,
|
||||
orientation,
|
||||
deserializer,
|
||||
orthogonalSize
|
||||
orthogonalSize,
|
||||
true
|
||||
) as BranchNode;
|
||||
}
|
||||
|
||||
@ -316,7 +318,8 @@ export class Gridview implements IDisposable {
|
||||
node: ISerializedNode,
|
||||
orientation: Orientation,
|
||||
deserializer: IViewDeserializer,
|
||||
orthogonalSize: number
|
||||
orthogonalSize: number,
|
||||
isRoot = false
|
||||
): Node {
|
||||
let result: Node;
|
||||
if (node.type === 'branch') {
|
||||
@ -333,12 +336,14 @@ export class Gridview implements IDisposable {
|
||||
} as INodeDescriptor;
|
||||
});
|
||||
|
||||
// HORIZONTAL => height=orthogonalsize width=size
|
||||
// VERTICAL => height=size width=orthogonalsize
|
||||
result = new BranchNode(
|
||||
orientation,
|
||||
this.proportionalLayout,
|
||||
this.styles,
|
||||
node.size,
|
||||
orthogonalSize,
|
||||
isRoot ? orthogonalSize : node.size,
|
||||
isRoot ? node.size : orthogonalSize,
|
||||
children
|
||||
);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user