mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 10:15:43 +03:00
only fire onCollapsed once when changing
This commit is contained in:
parent
28ec0f7462
commit
3a26f0fa12
1 changed files with 9 additions and 5 deletions
|
@ -26,23 +26,27 @@ class CollapseDistributor extends FixedDistributor {
|
|||
super(sizer, item, config);
|
||||
this.toggleSize = config && config.toggleSize;
|
||||
this.onCollapsed = config && config.onCollapsed;
|
||||
this.isCollapsed = false;
|
||||
}
|
||||
|
||||
resize(offset) {
|
||||
let newSize = this.sizeFromOffset(offset);
|
||||
if (newSize < this.toggleSize) {
|
||||
this.item.classList.add("collapsed");
|
||||
const isCollapsedSize = newSize < this.toggleSize;
|
||||
if (isCollapsedSize && !this.isCollapsed) {
|
||||
this.isCollapsed = true;
|
||||
if (this.onCollapsed) {
|
||||
this.onCollapsed(true, this.item);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.item.classList.remove("collapsed");
|
||||
else if (!isCollapsedSize && this.isCollapsed) {
|
||||
if (this.onCollapsed) {
|
||||
this.onCollapsed(false, this.item);
|
||||
}
|
||||
this.isCollapsed = false;
|
||||
}
|
||||
if (!isCollapsedSize) {
|
||||
super.resize(offset);
|
||||
}
|
||||
super.resize(offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue