dock-spawn-ts
Advanced tools
Comparing version 2.10.0 to 2.11.0
@@ -16,5 +16,4 @@ import { SplitterBar } from "./SplitterBar.js"; | ||
removeFromDOM(): void; | ||
removeSplittersFromDOM(): void; | ||
destroy(): void; | ||
_insertContainerIntoPanel(container: IDockContainer): void; | ||
_insertContainerIntoPanel(container: IDockContainer, afterElement: HTMLElement): void; | ||
/** | ||
@@ -21,0 +20,0 @@ * Sets the percentage of space the specified [container] takes in the split panel |
@@ -19,2 +19,3 @@ import { SplitterBar } from "./SplitterBar.js"; | ||
this.spiltterBars = []; | ||
let afterElement = null; | ||
for (let i = 0; i < this.childContainers.length - 1; i++) { | ||
@@ -26,6 +27,10 @@ let previousContainer = this.childContainers[i]; | ||
// Add the container and split bar to the panel's base div element | ||
this._insertContainerIntoPanel(previousContainer); | ||
this.panelElement.appendChild(splitterBar.barElement); | ||
if (!Array.from(this.panelElement.children).includes(previousContainer.containerElement)) | ||
this._insertContainerIntoPanel(previousContainer, afterElement); | ||
this.panelElement.insertBefore(splitterBar.barElement, previousContainer.containerElement.nextSibling); | ||
afterElement = splitterBar.barElement; | ||
} | ||
this._insertContainerIntoPanel(this.childContainers.slice(-1)[0]); | ||
let last = this.childContainers.slice(-1)[0]; | ||
if (!Array.from(this.panelElement.children).includes(last.containerElement)) | ||
this._insertContainerIntoPanel(last, afterElement); | ||
} | ||
@@ -44,3 +49,3 @@ performLayout(children, relayoutEvenIfEqual) { | ||
}); | ||
this.removeSplittersFromDOM(); | ||
this.spiltterBars.forEach((bar) => { Utils.removeNode(bar.barElement); }); | ||
// rebuild | ||
@@ -59,5 +64,2 @@ this.childContainers = children; | ||
}); | ||
this.removeSplittersFromDOM(); | ||
} | ||
removeSplittersFromDOM() { | ||
this.spiltterBars.forEach((bar) => { Utils.removeNode(bar.barElement); }); | ||
@@ -69,3 +71,3 @@ } | ||
} | ||
_insertContainerIntoPanel(container) { | ||
_insertContainerIntoPanel(container, afterElement) { | ||
if (!container) { | ||
@@ -75,4 +77,13 @@ console.error('container is undefined'); | ||
} | ||
Utils.removeNode(container.containerElement); | ||
this.panelElement.appendChild(container.containerElement); | ||
if (container.containerElement.parentNode != this.panelElement) { | ||
Utils.removeNode(container.containerElement); | ||
if (afterElement) | ||
this.panelElement.insertBefore(container.containerElement, afterElement.nextSibling); | ||
else { | ||
if (this.panelElement.children.length > 0) | ||
this.panelElement.insertBefore(container.containerElement, this.panelElement.children[0]); | ||
else | ||
this.panelElement.appendChild(container.containerElement); | ||
} | ||
} | ||
container.containerElement.classList.add(this.stackedVertical ? 'splitter-container-vertical' : 'splitter-container-horizontal'); | ||
@@ -79,0 +90,0 @@ } |
{ | ||
"name": "dock-spawn-ts", | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"description": "DockSpawn Typescript Version", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -28,2 +28,3 @@ import { SplitterBar } from "./SplitterBar.js"; | ||
this.spiltterBars = []; | ||
let afterElement: HTMLElement = null; | ||
for (let i = 0; i < this.childContainers.length - 1; i++) { | ||
@@ -36,6 +37,10 @@ let previousContainer = this.childContainers[i]; | ||
// Add the container and split bar to the panel's base div element | ||
this._insertContainerIntoPanel(previousContainer); | ||
this.panelElement.appendChild(splitterBar.barElement); | ||
if (!Array.from(this.panelElement.children).includes(previousContainer.containerElement)) | ||
this._insertContainerIntoPanel(previousContainer, afterElement); | ||
this.panelElement.insertBefore(splitterBar.barElement, previousContainer.containerElement.nextSibling); | ||
afterElement = splitterBar.barElement; | ||
} | ||
this._insertContainerIntoPanel(this.childContainers.slice(-1)[0]); | ||
let last = this.childContainers.slice(-1)[0]; | ||
if (!Array.from(this.panelElement.children).includes(last.containerElement)) | ||
this._insertContainerIntoPanel(last, afterElement); | ||
} | ||
@@ -52,8 +57,8 @@ | ||
Utils.removeNode(container.containerElement); | ||
} | ||
} | ||
}); | ||
this.spiltterBars.forEach((bar) => { Utils.removeNode(bar.barElement); }); | ||
this.removeSplittersFromDOM(); | ||
// rebuild | ||
@@ -73,6 +78,2 @@ this.childContainers = children; | ||
}); | ||
this.removeSplittersFromDOM(); | ||
} | ||
removeSplittersFromDOM() { | ||
this.spiltterBars.forEach((bar) => { Utils.removeNode(bar.barElement); }); | ||
@@ -86,3 +87,3 @@ } | ||
_insertContainerIntoPanel(container: IDockContainer) { | ||
_insertContainerIntoPanel(container: IDockContainer, afterElement: HTMLElement) { | ||
if (!container) { | ||
@@ -93,4 +94,13 @@ console.error('container is undefined'); | ||
Utils.removeNode(container.containerElement); | ||
this.panelElement.appendChild(container.containerElement); | ||
if (container.containerElement.parentNode != this.panelElement) { | ||
Utils.removeNode(container.containerElement); | ||
if (afterElement) | ||
this.panelElement.insertBefore(container.containerElement, afterElement.nextSibling); | ||
else { | ||
if (this.panelElement.children.length > 0) | ||
this.panelElement.insertBefore(container.containerElement, this.panelElement.children[0]); | ||
else | ||
this.panelElement.appendChild(container.containerElement); | ||
} | ||
} | ||
container.containerElement.classList.add( | ||
@@ -97,0 +107,0 @@ this.stackedVertical ? 'splitter-container-vertical' : 'splitter-container-horizontal' |
Sorry, the diff of this file is not supported yet
551852
8745