diff --git a/src/resizer/distributors/roomsublist2.js b/src/resizer/distributors/roomsublist2.js index d6bf8d6c7a..57a07ecda3 100644 --- a/src/resizer/distributors/roomsublist2.js +++ b/src/resizer/distributors/roomsublist2.js @@ -41,6 +41,14 @@ export class Layout { this._sectionHeights = Object.assign({}, initialSizes); // in-progress heights, while dragging. Committed on mouse-up. this._heights = []; + // use while manually resizing to cancel + // the resize for a given mouse position + // when the previous resize made the layout + // constrained + this._clampedOffset = 0; + // used while manually resizing, to clear + // _clampedOffset when the direction of resizing changes + this._lastOffset = 0; } setAvailableHeight(newSize) { @@ -268,6 +276,22 @@ export class Layout { this._sectionHeights[section.id] = this._heights[i]; }); } + + _setUncommittedSectionHeight(sectionIndex, offset) { + if (Math.sign(offset) != Math.sign(this._lastOffset)) { + this._clampedOffset = undefined; + } + if (this._clampedOffset !== undefined) { + if (offset < 0 && offset < this._clampedOffset) { + return; + } + if (offset > 0 && offset > this._clampedOffset) { + return; + } + } + this._clampedOffset = this._relayout(sectionIndex, offset); + this._lastOffset = offset; + } } class Handle { @@ -278,7 +302,10 @@ class Handle { } setHeight(height) { - this._layout._relayout(this._sectionIndex, height - this._initialHeight); + this._layout._setUncommittedSectionHeight( + this._sectionIndex, + height - this._initialHeight, + ); return this; }