try clear next item size when resizing so there is always one unsized item
This commit is contained in:
parent
1a2727f0af
commit
a130c44803
3 changed files with 55 additions and 9 deletions
|
@ -74,4 +74,8 @@ export default class ResizeItem {
|
||||||
callback(size, this.id, this.domNode);
|
callback(size, this.id, this.domNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearSize() {
|
||||||
|
this.sizer.clearItemSize(this.domNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,15 @@ class RoomSizer extends Sizer {
|
||||||
setItemSize(item, size) {
|
setItemSize(item, size) {
|
||||||
item.style.flexBasis = `${Math.round(size)}px`;
|
item.style.flexBasis = `${Math.round(size)}px`;
|
||||||
item.classList.add("resized-sized");
|
item.classList.add("resized-sized");
|
||||||
|
// const total = this.getTotalSize();
|
||||||
|
// const percent = size / total;
|
||||||
|
// const growFactor = Math.round(1 + (percent * 100));
|
||||||
|
// item.style.flexGrow = `${growFactor}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearItemSize(item) {
|
||||||
|
item.style.flexBasis = null;
|
||||||
|
item.classList.remove("resized-sized");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,16 +83,41 @@ class RoomDistributor {
|
||||||
return headerHeight + scrollItem.scrollHeight;
|
return headerHeight + scrollItem.scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
resize(size) {
|
_isSized(item) {
|
||||||
if (size < 0) {
|
return item.domNode.classList.contains("resized-sized");
|
||||||
console.log("NEGATIVE SIZE RESIZE RESIZE RESIZE!!!", size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resize(size, interactive = false) {
|
||||||
|
// console.log("*** starting resize session with size", size);
|
||||||
|
|
||||||
|
// grow/shrink items after first?
|
||||||
|
// const itemSize = this.item.size();
|
||||||
|
// //
|
||||||
|
// if (size < itemSize) {
|
||||||
|
// let nextItem = this.item.next();
|
||||||
|
// while (nextItem)
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (false && interactive) {
|
||||||
|
const nextItem = this.item.next();
|
||||||
|
if (nextItem) {
|
||||||
|
// let item = nextItem;
|
||||||
|
// let hasUnsizedProceedingItem = false;
|
||||||
|
// while (item) {
|
||||||
|
// if (this._isSized(item)) {
|
||||||
|
// hasUnsizedProceedingItem = true;
|
||||||
|
// item = null;
|
||||||
|
// } else {
|
||||||
|
// item = item.next();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (!hasUnsizedProceedingItem) {
|
||||||
|
nextItem.clearSize();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let item = this.item;
|
let item = this.item;
|
||||||
|
|
||||||
// cache result of this loop?
|
|
||||||
|
|
||||||
// move to item that is at position of cursor
|
|
||||||
// this would happen if the cursor goes beyond the min-height
|
|
||||||
while (item) {
|
while (item) {
|
||||||
// TODO: collapsed
|
// TODO: collapsed
|
||||||
if (this._isCollapsed(item)) {
|
if (this._isCollapsed(item)) {
|
||||||
|
@ -117,7 +151,7 @@ class RoomDistributor {
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeFromContainerOffset(containerOffset) {
|
resizeFromContainerOffset(containerOffset) {
|
||||||
this.resize(containerOffset - this.item.offset());
|
this.resize(containerOffset - this.item.offset(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,14 @@ export class Sizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearItemSize(item) {
|
||||||
|
if (this.vertical) {
|
||||||
|
item.style.height = null;
|
||||||
|
} else {
|
||||||
|
item.style.width = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param {MouseEvent} event the mouse event
|
@param {MouseEvent} event the mouse event
|
||||||
@return {number} the distance between the cursor and the edge of the container,
|
@return {number} the distance between the cursor and the edge of the container,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue