// Public
toggle() {
- if (this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this._isShown()) {
this.hide()
} else {
this.show()
}
show() {
- if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this._isTransitioning || this._isShown()) {
return
}
})
}
- this.setTransitioning(true)
+ this._isTransitioning = true
const complete = () => {
+ this._isTransitioning = false
+
this._element.classList.remove(CLASS_NAME_COLLAPSING)
this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW)
this._element.style[dimension] = ''
- this.setTransitioning(false)
-
EventHandler.trigger(this._element, EVENT_SHOWN)
}
}
hide() {
- if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this._isTransitioning || !this._isShown()) {
return
}
const trigger = this._triggerArray[i]
const elem = getElementFromSelector(trigger)
- if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
+ if (elem && !this._isShown(elem)) {
trigger.classList.add(CLASS_NAME_COLLAPSED)
trigger.setAttribute('aria-expanded', false)
}
}
}
- this.setTransitioning(true)
+ this._isTransitioning = true
const complete = () => {
- this.setTransitioning(false)
+ this._isTransitioning = false
this._element.classList.remove(CLASS_NAME_COLLAPSING)
this._element.classList.add(CLASS_NAME_COLLAPSE)
EventHandler.trigger(this._element, EVENT_HIDDEN)
this._queueCallback(complete, this._element, true)
}
- setTransitioning(isTransitioning) {
- this._isTransitioning = isTransitioning
+ _isShown(element = this._element) {
+ return element.classList.contains(CLASS_NAME_SHOW)
}
// Private
return
}
- const isOpen = element.classList.contains(CLASS_NAME_SHOW)
+ const isOpen = this._isShown(element)
triggerArray.forEach(elem => {
if (isOpen) {