Add initialRightWidth and allow for number values too.

This commit is contained in:
trading_peter 2025-05-09 13:43:33 +02:00
parent bb5c63fcdc
commit 76b88a508a
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@tp/tp-splitter",
"version": "1.5.1",
"version": "1.6.0",
"description": "",
"main": "tp-splitter.js",
"scripts": {

View File

@ -61,6 +61,7 @@ class TpVSplitter extends LitElement {
minSideWidth: { type: Number },
lateResize: { type: Boolean }, // if true, the panels will not be reized until the dragging is finished.
initialLeftWidth: { type: String },
initialRightWidth: { type: String },
};
}
@ -86,7 +87,15 @@ class TpVSplitter extends LitElement {
firstUpdated() {
if (this.initialLeftWidth) {
this.style.gridTemplateColumns = `${this.initialLeftWidth} var(--tp-splitter-width, 5px) 1fr`;
if (this.initialRightWidth) {
console.warn('Both initialLeftWidth and initialRightWidth are set. Using initialLeftWidth.');
}
const leftWidth = parseInt(this.initialLeftWidth, 10);
this.style.gridTemplateColumns = `${leftWidth}px var(--tp-splitter-width, 5px) 1fr`;
} else if (this.initialRightWidth) {
const rightWidth = parseInt(this.initialRightWidth, 10);
this.style.gridTemplateColumns = `1fr var(--tp-splitter-width, 5px) ${rightWidth}px`;
}
}