fix(splitter): minSize behavior during fast mouse movement

pull/7099/head
Jakub Michálek 2025-01-14 19:18:22 +01:00
parent f481158d36
commit 9544fa57aa
1 changed files with 29 additions and 12 deletions

View File

@ -139,14 +139,17 @@ export default {
newNextPanelSize = this.nextPanelSize - newPos;
}
if (this.validateResize(newPrevPanelSize, newNextPanelSize)) {
this.prevPanelElement.style.flexBasis = 'calc(' + newPrevPanelSize + '% - ' + (this.panels.length - 1) * this.gutterSize + 'px)';
this.nextPanelElement.style.flexBasis = 'calc(' + newNextPanelSize + '% - ' + (this.panels.length - 1) * this.gutterSize + 'px)';
this.panelSizes[this.prevPanelIndex] = newPrevPanelSize;
this.panelSizes[this.prevPanelIndex + 1] = newNextPanelSize;
this.prevSize = parseFloat(newPrevPanelSize).toFixed(4);
if (!this.validateResize(newPrevPanelSize, newNextPanelSize)) {
newPrevPanelSize = Math.min(Math.max(this.prevPanelMinSize, newPrevPanelSize), 100 - this.nextPanelMinSize);
newNextPanelSize = Math.min(Math.max(this.nextPanelMinSize, newNextPanelSize), 100 - this.prevPanelMinSize);
}
this.prevPanelElement.style.flexBasis = 'calc(' + newPrevPanelSize + '% - ' + (this.panels.length - 1) * this.gutterSize + 'px)';
this.nextPanelElement.style.flexBasis = 'calc(' + newNextPanelSize + '% - ' + (this.panels.length - 1) * this.gutterSize + 'px)';
this.panelSizes[this.prevPanelIndex] = newPrevPanelSize;
this.panelSizes[this.prevPanelIndex + 1] = newNextPanelSize;
this.prevSize = parseFloat(newPrevPanelSize).toFixed(4);
this.$emit('resize', { originalEvent: event, sizes: this.panelSizes });
},
onResizeEnd(event) {
@ -275,15 +278,11 @@ export default {
if (newPrevPanelSize > 100 || newPrevPanelSize < 0) return false;
if (newNextPanelSize > 100 || newNextPanelSize < 0) return false;
let prevPanelMinSize = getVNodeProp(this.panels[this.prevPanelIndex], 'minSize');
if (this.panels[this.prevPanelIndex].props && prevPanelMinSize && prevPanelMinSize > newPrevPanelSize) {
if (this.prevPanelMinSize > newPrevPanelSize) {
return false;
}
let newPanelMinSize = getVNodeProp(this.panels[this.prevPanelIndex + 1], 'minSize');
if (this.panels[this.prevPanelIndex + 1].props && newPanelMinSize && newPanelMinSize > newNextPanelSize) {
if (this.nextPanelMinSize > newNextPanelSize) {
return false;
}
@ -394,6 +393,24 @@ export default {
nested: this.$parentInstance?.nestedState
}
};
},
prevPanelMinSize() {
const prevPanelMinSize = getVNodeProp(this.panels[this.prevPanelIndex], 'minSize');
if (this.panels[this.prevPanelIndex].props && prevPanelMinSize) {
return prevPanelMinSize;
}
return 0;
},
nextPanelMinSize() {
const nextPanelMinSize = getVNodeProp(this.panels[this.prevPanelIndex + 1], 'minSize');
if (this.panels[this.prevPanelIndex + 1].props && nextPanelMinSize) {
return nextPanelMinSize;
}
return 0;
}
}
};