WIP2 for making smart resizer work, sort of works now but shows big scrollbar
This commit is contained in:
parent
5eba8210b8
commit
4bd6ce8e2c
3 changed files with 42 additions and 41 deletions
|
@ -33,7 +33,7 @@ limitations under the License.
|
||||||
|
|
||||||
.mx_RoomSubList {
|
.mx_RoomSubList {
|
||||||
min-height: 31px;
|
min-height: 31px;
|
||||||
flex: 0 100000000 auto;
|
flex: 0 1 auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
@ -50,15 +50,15 @@ limitations under the License.
|
||||||
flex: none !important;
|
flex: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_RoomSubList.resized-all {
|
// .mx_RoomSubList.resized-all {
|
||||||
flex: 0 1 auto;
|
// flex: 0 1 auto;
|
||||||
}
|
// }
|
||||||
|
|
||||||
.mx_RoomSubList.resized-sized {
|
.mx_RoomSubList.resized-sized {
|
||||||
/* resizer set max-height on resized-sized,
|
/* resizer set max-height on resized-sized,
|
||||||
so that limits the height and hence
|
so that limits the height and hence
|
||||||
needs a very small flex-shrink */
|
needs a very small flex-shrink */
|
||||||
flex: 0 10000 auto;
|
flex: 1 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_RoomSubList_labelContainer {
|
.mx_RoomSubList_labelContainer {
|
||||||
|
|
|
@ -69,7 +69,6 @@ export default class ResizeItem {
|
||||||
|
|
||||||
setSize(size) {
|
setSize(size) {
|
||||||
this.sizer.setItemSize(this.domNode, size);
|
this.sizer.setItemSize(this.domNode, size);
|
||||||
console.log("resizing", this.domNode, "to", size, this.size());
|
|
||||||
const callback = this.resizer.distributorCtor.onResized;
|
const callback = this.resizer.distributorCtor.onResized;
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(size, this.id, this.domNode);
|
callback(size, this.id, this.domNode);
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {Sizer} from "./sizer";
|
||||||
class RoomSizer extends Sizer {
|
class RoomSizer extends Sizer {
|
||||||
setItemSize(item, size) {
|
setItemSize(item, size) {
|
||||||
item.style.maxHeight = `${Math.round(size)}px`;
|
item.style.maxHeight = `${Math.round(size)}px`;
|
||||||
|
item.classList.add("resized-sized");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +46,10 @@ const MIN_SIZE = 70;
|
||||||
// - items at maxContentHeight can't be resized larger
|
// - items at maxContentHeight can't be resized larger
|
||||||
|
|
||||||
// if you shrink the predecesor, and start dragging down again afterwards, which item has to grow?
|
// if you shrink the predecesor, and start dragging down again afterwards, which item has to grow?
|
||||||
|
/*
|
||||||
|
either items before (starting from first or last)
|
||||||
|
or
|
||||||
|
*/
|
||||||
class RoomDistributor {
|
class RoomDistributor {
|
||||||
constructor(item) {
|
constructor(item) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
|
@ -55,24 +59,14 @@ class RoomDistributor {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the remainder of size it didn't consume for this item
|
_isCollapsed(item) {
|
||||||
_sizeItem(item, size) {
|
return item.domNode.classList.contains("mx_RoomSubList_hidden");
|
||||||
// if collapsed, do nothing and subtract own height
|
}
|
||||||
if (item.domNode.classList.contains("mx_RoomSubList_hidden")) {
|
|
||||||
return;
|
_contentSize(item) {
|
||||||
} else if (size < MIN_SIZE) {
|
const scrollItem = item.domNode.querySelector(".mx_RoomSubList_scroll");
|
||||||
item.setSize(MIN_SIZE);
|
const headerHeight = item.size() - scrollItem.offsetHeight;
|
||||||
} else {
|
return headerHeight + scrollItem.scrollHeight;
|
||||||
const scrollItem = item.domNode.querySelector(".mx_RoomSubList_scroll");
|
|
||||||
const headerHeight = item.size() - scrollItem.offsetHeight;
|
|
||||||
const maxContentHeight = headerHeight + scrollItem.scrollHeight;
|
|
||||||
// avoid flexbox growing larger than the content height
|
|
||||||
if (size > maxContentHeight) {
|
|
||||||
item.setSize(maxContentHeight);
|
|
||||||
} else {
|
|
||||||
item.setSize(size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resize(size) {
|
resize(size) {
|
||||||
|
@ -80,28 +74,36 @@ class RoomDistributor {
|
||||||
console.log("NEGATIVE SIZE RESIZE RESIZE RESIZE!!!", size);
|
console.log("NEGATIVE SIZE RESIZE RESIZE RESIZE!!!", size);
|
||||||
}
|
}
|
||||||
let item = this.item;
|
let item = this.item;
|
||||||
|
|
||||||
|
// cache result of this loop?
|
||||||
|
|
||||||
// move to item that is at position of cursor
|
// move to item that is at position of cursor
|
||||||
// this would happen if the cursor goes beyond the min-height
|
// this would happen if the cursor goes beyond the min-height
|
||||||
while (item && size < 0) {
|
while (item) {
|
||||||
item = item.previous();
|
// TODO: collapsed
|
||||||
if (item) {
|
if (size <= MIN_SIZE) {
|
||||||
size = item.size() - size - this._handleSize();
|
item.setSize(MIN_SIZE);
|
||||||
}
|
const remainder = MIN_SIZE - size;
|
||||||
}
|
|
||||||
// change size of item and previous items from here
|
|
||||||
while(item && size > 0) {
|
|
||||||
const itemSize = item.size();
|
|
||||||
this._sizeItem(item, size);
|
|
||||||
const delta = item.size() - itemSize;
|
|
||||||
const remainder = size - delta;
|
|
||||||
// pass remainder to previous item
|
|
||||||
if (remainder !== 0) {
|
|
||||||
item = item.previous();
|
item = item.previous();
|
||||||
if (item) {
|
if (item) {
|
||||||
size = item.size() - remainder - this._handleSize();
|
size = item.size() - remainder - this._handleSize();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
item = null;
|
else {
|
||||||
|
const contentSize = this._contentSize(item);
|
||||||
|
if (size > contentSize) {
|
||||||
|
item.setSize(contentSize);
|
||||||
|
const remainder = size - contentSize;
|
||||||
|
item = item.previous();
|
||||||
|
if (item) {
|
||||||
|
size = item.size() + remainder; // todo: handle size here?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item.setSize(size);
|
||||||
|
item = null;
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue