mirror of
https://github.com/mathuo/dockview
synced 2025-08-29 13:36:31 +00:00
Merge pull request #667 from RayJason/fix/layout-view-size-calc
fix: splitview layout view size with hidden view
This commit is contained in:
commit
35b3ee2b0f
@ -811,19 +811,21 @@ export class Splitview {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sashCount = this.viewItems.length - 1;
|
const visibleViewItemCount = this.viewItems.filter((i) => i.visible).length
|
||||||
const marginReducedSize =
|
|
||||||
(this.margin * sashCount) / this.viewItems.length;
|
const sashCount = visibleViewItemCount - 1
|
||||||
|
const marginReducedSize = (this.margin * sashCount) / visibleViewItemCount
|
||||||
|
|
||||||
let totalLeftOffset = 0;
|
let totalLeftOffset = 0;
|
||||||
const viewLeftOffsets: number[] = [];
|
const viewLeftOffsets: number[] = [];
|
||||||
|
|
||||||
|
// Calc sashes style
|
||||||
for (let i = 0; i < this.viewItems.length - 1; i++) {
|
for (let i = 0; i < this.viewItems.length - 1; i++) {
|
||||||
totalLeftOffset += this.viewItems[i].size;
|
totalLeftOffset += this.viewItems[i].size;
|
||||||
viewLeftOffsets.push(totalLeftOffset);
|
viewLeftOffsets.push(totalLeftOffset);
|
||||||
|
|
||||||
const offset = Math.min(
|
const offset = Math.min(
|
||||||
Math.max(0, totalLeftOffset - 2),
|
Math.max(0, totalLeftOffset - (1 + this.margin) / 2),
|
||||||
this.size - this.margin
|
this.size - this.margin
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -836,10 +838,12 @@ export class Splitview {
|
|||||||
this.sashes[i].container.style.top = `${offset}px`;
|
this.sashes[i].container.style.top = `${offset}px`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calc views style
|
||||||
this.viewItems.forEach((view, i) => {
|
this.viewItems.forEach((view, i) => {
|
||||||
const size = view.size - marginReducedSize;
|
const size = view.size - marginReducedSize;
|
||||||
const offset =
|
const offset =
|
||||||
i === 0
|
i === 0 || sashCount === 0
|
||||||
? 0
|
? 0
|
||||||
: viewLeftOffsets[i - 1] +
|
: viewLeftOffsets[i - 1] +
|
||||||
(i / sashCount) * marginReducedSize;
|
(i / sashCount) * marginReducedSize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user