From 8d1e105b503392764c7a989b530ab3f6705fc8c0 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 28 Jan 2019 18:02:36 +0100 Subject: [PATCH] add option for whitespace behaviour and handle height --- src/components/views/rooms/RoomList.js | 6 +++++- src/resizer/distributors/roomsublist2.js | 13 +++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index f79ca64869..8818c9026e 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -82,6 +82,10 @@ module.exports = React.createClass({ this.collapsedState = collapsedJson ? JSON.parse(collapsedJson) : {}; this._layoutSections = []; + const options = { + allowWhitespace: false, + handleHeight: 1, + }; this._layout = new Layout((key, size) => { const subList = this._subListRefs[key]; if (subList) { @@ -95,7 +99,7 @@ module.exports = React.createClass({ window.localStorage.setItem("mx_roomlist_sizes", JSON.stringify(this.subListSizes)); } - }, this.subListSizes, this.collapsedState); + }, this.subListSizes, this.collapsedState, options); return { isLoadingLeftRooms: false, diff --git a/src/resizer/distributors/roomsublist2.js b/src/resizer/distributors/roomsublist2.js index 57a07ecda3..6f607f2fe8 100644 --- a/src/resizer/distributors/roomsublist2.js +++ b/src/resizer/distributors/roomsublist2.js @@ -16,9 +16,6 @@ limitations under the License. import FixedDistributor from "./fixed"; -// const allowWhitespace = true; -const handleHeight = 1; - function clamp(height, min, max) { if (height > max) return max; if (height < min) return min; @@ -26,7 +23,7 @@ function clamp(height, min, max) { } export class Layout { - constructor(applyHeight, initialSizes, collapsedState) { + constructor(applyHeight, initialSizes, collapsedState, options) { // callback to set height of section this._applyHeight = applyHeight; // list of {id, count} objects, @@ -49,6 +46,9 @@ export class Layout { // used while manually resizing, to clear // _clampedOffset when the direction of resizing changes this._lastOffset = 0; + + this._allowWhitespace = options && options.allowWhitespace; + this._handleHeight = (options && options.handleHeight) || 0; } setAvailableHeight(newSize) { @@ -112,7 +112,7 @@ export class Layout { const collapsed = this._collapsedState[section.id]; return count + (collapsed ? 0 : 1); }, 0); - return this._availableHeight - ((nonCollapsedSectionCount - 1) * handleHeight); + return this._availableHeight - ((nonCollapsedSectionCount - 1) * this._handleHeight); } _applyNewSize() { @@ -138,9 +138,10 @@ export class Layout { if (collapsed) { return this._sectionHeight(0); + } else if (!this._allowWhitespace) { + return this._sectionHeight(section.count); } else { return 100000; - // return this._sectionHeight(section.count); } }