only fire onCollapsed once when changing
parent
28ec0f7462
commit
3a26f0fa12
|
@ -26,23 +26,27 @@ class CollapseDistributor extends FixedDistributor {
|
||||||
super(sizer, item, config);
|
super(sizer, item, config);
|
||||||
this.toggleSize = config && config.toggleSize;
|
this.toggleSize = config && config.toggleSize;
|
||||||
this.onCollapsed = config && config.onCollapsed;
|
this.onCollapsed = config && config.onCollapsed;
|
||||||
|
this.isCollapsed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
resize(offset) {
|
resize(offset) {
|
||||||
let newSize = this.sizeFromOffset(offset);
|
let newSize = this.sizeFromOffset(offset);
|
||||||
if (newSize < this.toggleSize) {
|
const isCollapsedSize = newSize < this.toggleSize;
|
||||||
this.item.classList.add("collapsed");
|
if (isCollapsedSize && !this.isCollapsed) {
|
||||||
|
this.isCollapsed = true;
|
||||||
if (this.onCollapsed) {
|
if (this.onCollapsed) {
|
||||||
this.onCollapsed(true, this.item);
|
this.onCollapsed(true, this.item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (!isCollapsedSize && this.isCollapsed) {
|
||||||
this.item.classList.remove("collapsed");
|
|
||||||
if (this.onCollapsed) {
|
if (this.onCollapsed) {
|
||||||
this.onCollapsed(false, this.item);
|
this.onCollapsed(false, this.item);
|
||||||
}
|
}
|
||||||
|
this.isCollapsed = false;
|
||||||
|
}
|
||||||
|
if (!isCollapsedSize) {
|
||||||
|
super.resize(offset);
|
||||||
}
|
}
|
||||||
super.resize(offset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue