Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2021-06-10 01:16:54 +0300
committerXhmikosR <xhmikosr@gmail.com>2021-07-29 16:30:02 +0300
commit5882d5dbe85edc5e6d9ca1cdbf1fc94a0698ae82 (patch)
tree19222733f38b03bc77a003434ad3dd5a55511533 /js/src/collapse.js
parent4961ad0c63849d360edf7c23a15001ff56d58639 (diff)
Add a helper function to check for showing
Also, remove the `isTransitioning()` helper.
Diffstat (limited to 'js/src/collapse.js')
-rw-r--r--js/src/collapse.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js
index fcb8be6d7d..c15bffa84f 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -113,7 +113,7 @@ class Collapse extends BaseComponent {
// Public
toggle() {
- if (this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this._isShown()) {
this.hide()
} else {
this.show()
@@ -121,7 +121,7 @@ class Collapse extends BaseComponent {
}
show() {
- if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this._isTransitioning || this._isShown()) {
return
}
@@ -184,16 +184,16 @@ class Collapse extends BaseComponent {
})
}
- 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)
}
@@ -205,7 +205,7 @@ class Collapse extends BaseComponent {
}
hide() {
- if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this._isTransitioning || !this._isShown()) {
return
}
@@ -229,17 +229,17 @@ class Collapse extends BaseComponent {
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)
@@ -250,8 +250,8 @@ class Collapse extends BaseComponent {
this._queueCallback(complete, this._element, true)
}
- setTransitioning(isTransitioning) {
- this._isTransitioning = isTransitioning
+ _isShown(element = this._element) {
+ return element.classList.contains(CLASS_NAME_SHOW)
}
// Private
@@ -296,7 +296,7 @@ class Collapse extends BaseComponent {
return
}
- const isOpen = element.classList.contains(CLASS_NAME_SHOW)
+ const isOpen = this._isShown(element)
triggerArray.forEach(elem => {
if (isOpen) {