mirror of https://github.com/vector-im/riot-web
add option for whitespace behaviour and handle height
parent
88f25dec4d
commit
8d1e105b50
|
@ -82,6 +82,10 @@ module.exports = React.createClass({
|
||||||
this.collapsedState = collapsedJson ? JSON.parse(collapsedJson) : {};
|
this.collapsedState = collapsedJson ? JSON.parse(collapsedJson) : {};
|
||||||
this._layoutSections = [];
|
this._layoutSections = [];
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
allowWhitespace: false,
|
||||||
|
handleHeight: 1,
|
||||||
|
};
|
||||||
this._layout = new Layout((key, size) => {
|
this._layout = new Layout((key, size) => {
|
||||||
const subList = this._subListRefs[key];
|
const subList = this._subListRefs[key];
|
||||||
if (subList) {
|
if (subList) {
|
||||||
|
@ -95,7 +99,7 @@ module.exports = React.createClass({
|
||||||
window.localStorage.setItem("mx_roomlist_sizes",
|
window.localStorage.setItem("mx_roomlist_sizes",
|
||||||
JSON.stringify(this.subListSizes));
|
JSON.stringify(this.subListSizes));
|
||||||
}
|
}
|
||||||
}, this.subListSizes, this.collapsedState);
|
}, this.subListSizes, this.collapsedState, options);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isLoadingLeftRooms: false,
|
isLoadingLeftRooms: false,
|
||||||
|
|
|
@ -16,9 +16,6 @@ limitations under the License.
|
||||||
|
|
||||||
import FixedDistributor from "./fixed";
|
import FixedDistributor from "./fixed";
|
||||||
|
|
||||||
// const allowWhitespace = true;
|
|
||||||
const handleHeight = 1;
|
|
||||||
|
|
||||||
function clamp(height, min, max) {
|
function clamp(height, min, max) {
|
||||||
if (height > max) return max;
|
if (height > max) return max;
|
||||||
if (height < min) return min;
|
if (height < min) return min;
|
||||||
|
@ -26,7 +23,7 @@ function clamp(height, min, max) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Layout {
|
export class Layout {
|
||||||
constructor(applyHeight, initialSizes, collapsedState) {
|
constructor(applyHeight, initialSizes, collapsedState, options) {
|
||||||
// callback to set height of section
|
// callback to set height of section
|
||||||
this._applyHeight = applyHeight;
|
this._applyHeight = applyHeight;
|
||||||
// list of {id, count} objects,
|
// list of {id, count} objects,
|
||||||
|
@ -49,6 +46,9 @@ export class Layout {
|
||||||
// used while manually resizing, to clear
|
// used while manually resizing, to clear
|
||||||
// _clampedOffset when the direction of resizing changes
|
// _clampedOffset when the direction of resizing changes
|
||||||
this._lastOffset = 0;
|
this._lastOffset = 0;
|
||||||
|
|
||||||
|
this._allowWhitespace = options && options.allowWhitespace;
|
||||||
|
this._handleHeight = (options && options.handleHeight) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAvailableHeight(newSize) {
|
setAvailableHeight(newSize) {
|
||||||
|
@ -112,7 +112,7 @@ export class Layout {
|
||||||
const collapsed = this._collapsedState[section.id];
|
const collapsed = this._collapsedState[section.id];
|
||||||
return count + (collapsed ? 0 : 1);
|
return count + (collapsed ? 0 : 1);
|
||||||
}, 0);
|
}, 0);
|
||||||
return this._availableHeight - ((nonCollapsedSectionCount - 1) * handleHeight);
|
return this._availableHeight - ((nonCollapsedSectionCount - 1) * this._handleHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
_applyNewSize() {
|
_applyNewSize() {
|
||||||
|
@ -138,9 +138,10 @@ export class Layout {
|
||||||
|
|
||||||
if (collapsed) {
|
if (collapsed) {
|
||||||
return this._sectionHeight(0);
|
return this._sectionHeight(0);
|
||||||
|
} else if (!this._allowWhitespace) {
|
||||||
|
return this._sectionHeight(section.count);
|
||||||
} else {
|
} else {
|
||||||
return 100000;
|
return 100000;
|
||||||
// return this._sectionHeight(section.count);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue