]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Carousel: move carousel default interval to `_getConfig()` and simplify it
authorGeoSot <geo.sotis@gmail.com>
Thu, 9 Sep 2021 23:11:14 +0000 (02:11 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Tue, 21 Dec 2021 15:37:24 +0000 (17:37 +0200)
js/src/carousel.js

index 856d70dac003e0750f852bff2bbc06f2ee74f7d8..336bcd261a559627d05b5564167abde331b1eaf4 100644 (file)
@@ -161,7 +161,7 @@ class Carousel extends BaseComponent {
       this._interval = null
     }
 
-    if (this._config && this._config.interval && !this._isPaused) {
+    if (this._config.interval && !this._isPaused) {
       this._updateInterval()
 
       this._interval = setInterval(
@@ -206,6 +206,11 @@ class Carousel extends BaseComponent {
   }
 
   // Private
+  _configAfterMerge(config) {
+    config.defaultInterval = config.interval
+    return config
+  }
+
   _addEventListeners() {
     if (this._config.keyboard) {
       EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event))
@@ -318,12 +323,7 @@ class Carousel extends BaseComponent {
 
     const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10)
 
-    if (elementInterval) {
-      this._config.defaultInterval = this._config.defaultInterval || this._config.interval
-      this._config.interval = elementInterval
-    } else {
-      this._config.interval = this._config.defaultInterval || this._config.interval
-    }
+    this._config.interval = elementInterval || this._config.defaultInterval
   }
 
   _slide(directionOrOrder, element) {