From 46fa98fd8cf47148d0ac97034b9d89bfcfe3b96f Mon Sep 17 00:00:00 2001 From: mathuo <{ID}+{username}@users.noreply.github.com> Date: Sat, 10 Apr 2021 22:03:14 +0100 Subject: [PATCH] bug: remove unwanted code --- packages/dockview/src/gridview/gridview.ts | 71 +--------------------- 1 file changed, 3 insertions(+), 68 deletions(-) diff --git a/packages/dockview/src/gridview/gridview.ts b/packages/dockview/src/gridview/gridview.ts index 6f61df310..f4d7626f9 100644 --- a/packages/dockview/src/gridview/gridview.ts +++ b/packages/dockview/src/gridview/gridview.ts @@ -228,10 +228,7 @@ const serializeBranchNode = ( data: node.children.map((c) => serializeBranchNode(c, orthogonal(orientation)) ), - size: - orientation === Orientation.HORIZONTAL - ? node.box.width - : node.box.height, + size, }; }; @@ -258,56 +255,6 @@ export interface INodeDescriptor { export interface IViewDeserializer { fromJSON: (data: ISerializedLeafNode) => IGridView; } - -function getDimensions( - node: SerializedGridObject, - orientation: Orientation -): { width?: number; height?: number } { - if (node.type === 'branch') { - const childrenDimensions = (node.data as SerializedGridObject[]).map( - (c) => getDimensions(c, orthogonal(orientation)) - ); - - if (orientation === Orientation.VERTICAL) { - const width = - node.size || - (childrenDimensions.length === 0 - ? undefined - : Math.max(...childrenDimensions.map((d) => d.width || 0))); - const height = - childrenDimensions.length === 0 - ? undefined - : childrenDimensions.reduce( - (r, d) => r + (d.height || 0), - 0 - ); - return { width, height }; - } else { - const width = - childrenDimensions.length === 0 - ? undefined - : childrenDimensions.reduce( - (r, d) => r + (d.width || 0), - 0 - ); - const height = - node.size || - (childrenDimensions.length === 0 - ? undefined - : Math.max( - ...childrenDimensions.map((d) => d.height || 0) - )); - return { width, height }; - } - } else { - const width = - orientation === Orientation.VERTICAL ? node.size : undefined; - const height = - orientation === Orientation.VERTICAL ? undefined : node.size; - return { width, height }; - } -} - export class Gridview implements IDisposable { private _root: BranchNode | undefined; public readonly element: HTMLElement; @@ -318,15 +265,6 @@ export class Gridview implements IDisposable { public serialize() { const root = serializeBranchNode(this.getView(), this.orientation); - const { width, height } = getDimensions(root, this.orientation); - - console.log('test'); - if (width !== this.width) { - console.log(`width ${width} !== this.width ${this.width}`); - } - if (height !== this.height) { - console.log(`height ${height} !== this.height ${this.height}`); - } return { root, @@ -354,10 +292,7 @@ export class Gridview implements IDisposable { public deserialize(json: any, deserializer: IViewDeserializer) { const orientation = json.orientation; - const height = - orientation === Orientation.VERTICAL ? json.height : json.width; - - // this.orientation = orientation; + const height = json.height; this._deserialize( json.root as ISerializedBranchNode, orientation, @@ -374,7 +309,7 @@ export class Gridview implements IDisposable { ): void { this.root = this._deserializeNode( root, - orthogonal(orientation), + orientation, deserializer, orthogonalSize ) as BranchNode;