Return all widths and heights in the resize done event.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/tp-splitter",
|
"name": "@tp/tp-splitter",
|
||||||
"version": "1.8.0",
|
"version": "2.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "tp-splitter.js",
|
"main": "tp-splitter.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -124,17 +124,28 @@ class TpHSplitter extends LitElement {
|
|||||||
document.body.style['userSelect'] = '';
|
document.body.style['userSelect'] = '';
|
||||||
this.dragging = false;
|
this.dragging = false;
|
||||||
|
|
||||||
let finalHeight;
|
let finalTopHeight;
|
||||||
if (this.lateResize && this._bufferedDelta) {
|
if (this.lateResize && this._bufferedDelta) {
|
||||||
finalHeight = this._topHeight + this._bufferedDelta;
|
finalTopHeight = this._topHeight + this._bufferedDelta;
|
||||||
this.splitter.style.transform = '';
|
this.splitter.style.transform = '';
|
||||||
this.style.gridTemplateRows = `${finalHeight}px 5px 1fr`;
|
this.style.gridTemplateRows = `${finalTopHeight}px 5px 1fr`;
|
||||||
this._bufferedDelta = 0;
|
this._bufferedDelta = 0;
|
||||||
} else {
|
} else {
|
||||||
finalHeight = this.top.offsetHeight;
|
finalTopHeight = this.top.offsetHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent('resize-done', { detail: finalHeight, bubbles: true, composed: true }));
|
// Calculate bottom height
|
||||||
|
const splitterWidth = parseInt(getComputedStyle(this).getPropertyValue('--tp-splitter-width')) || 5;
|
||||||
|
const finalBottomHeight = this.offsetHeight - finalTopHeight - splitterWidth;
|
||||||
|
|
||||||
|
this.dispatchEvent(new CustomEvent('resize-done', {
|
||||||
|
detail: {
|
||||||
|
topHeight: finalTopHeight,
|
||||||
|
bottomHeight: finalBottomHeight
|
||||||
|
},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
_resize(e) {
|
_resize(e) {
|
||||||
|
|||||||
@@ -123,17 +123,28 @@ class TpVSplitter extends LitElement {
|
|||||||
document.body.style['userSelect'] = '';
|
document.body.style['userSelect'] = '';
|
||||||
this.dragging = false;
|
this.dragging = false;
|
||||||
|
|
||||||
let finalWidth;
|
let finalLeftWidth;
|
||||||
if (this.lateResize && this._bufferedDelta) {
|
if (this.lateResize && this._bufferedDelta) {
|
||||||
finalWidth = this._leftWidth + this._bufferedDelta;
|
finalLeftWidth = this._leftWidth + this._bufferedDelta;
|
||||||
this.splitter.style.transform = '';
|
this.splitter.style.transform = '';
|
||||||
this.style.gridTemplateColumns = `${finalWidth}px 5px 1fr`;
|
this.style.gridTemplateColumns = `${finalLeftWidth}px 5px 1fr`;
|
||||||
this._bufferedDelta = 0;
|
this._bufferedDelta = 0;
|
||||||
} else {
|
} else {
|
||||||
finalWidth = this.left.offsetWidth;
|
finalLeftWidth = this.left.offsetWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent('resize-done', { detail: finalWidth, bubbles: true, composed: true }));
|
// Calculate right width
|
||||||
|
const splitterWidth = parseInt(getComputedStyle(this).getPropertyValue('--tp-splitter-width')) || 5;
|
||||||
|
const finalRightWidth = this.offsetWidth - finalLeftWidth - splitterWidth;
|
||||||
|
|
||||||
|
this.dispatchEvent(new CustomEvent('resize-done', {
|
||||||
|
detail: {
|
||||||
|
leftWidth: finalLeftWidth,
|
||||||
|
rightWidth: finalRightWidth
|
||||||
|
},
|
||||||
|
bubbles: true,
|
||||||
|
composed: true
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
_resize(e) {
|
_resize(e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user