From 3a26f0fa12bdb8384cd89eb6009efb8d96ff580a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 16 Oct 2018 18:43:13 +0200 Subject: [PATCH] only fire onCollapsed once when changing --- src/resizer/distributors.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/resizer/distributors.js b/src/resizer/distributors.js index 8b33ccabba..dbc35fc6c9 100644 --- a/src/resizer/distributors.js +++ b/src/resizer/distributors.js @@ -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); } }