adjust room distributor to roomsublist dom structure

also better classes to apply
This commit is contained in:
Bruno Windels 2018-11-26 14:41:15 +01:00
parent 231d8fff6e
commit 0939a40d3a

View file

@ -22,15 +22,14 @@ class RoomSizer extends Sizer {
const isString = typeof size === "string"; const isString = typeof size === "string";
const cl = item.classList; const cl = item.classList;
if (isString) { if (isString) {
item.style.flex = null; if (size === "resized-all") {
if (size === "show-content") { cl.add("resized-all");
cl.add("show-content"); cl.remove("resized-sized");
cl.remove("show-available");
item.style.maxHeight = null; item.style.maxHeight = null;
} }
} else { } else {
cl.add("show-available"); cl.add("resized-sized");
//item.style.flex = `0 1 ${Math.round(size)}px`; cl.remove("resized-all");
item.style.maxHeight = `${Math.round(size)}px`; item.style.maxHeight = `${Math.round(size)}px`;
} }
} }
@ -39,9 +38,10 @@ class RoomSizer extends Sizer {
class RoomDistributor extends FixedDistributor { class RoomDistributor extends FixedDistributor {
resize(offset) { resize(offset) {
const itemSize = offset - this.sizer.getItemOffset(this.item); const itemSize = offset - this.sizer.getItemOffset(this.item);
const scrollItem = this.item.querySelector(".mx_RoomSubList_scroll");
if (itemSize > this.item.scrollHeight) { const fixedHeight = this.item.offsetHeight - scrollItem.offsetHeight;
this.sizer.setItemSize(this.item, "show-content"); if (itemSize > (fixedHeight + scrollItem.scrollHeight)) {
this.sizer.setItemSize(this.item, "resized-all");
} else { } else {
this.sizer.setItemSize(this.item, itemSize); this.sizer.setItemSize(this.item, itemSize);
} }