diff options
author | GeoSot <geo.sotis@gmail.com> | 2021-12-10 19:18:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 19:18:18 +0300 |
commit | 886b940796b3595a03b44230ca8b78197c5ee1c5 (patch) | |
tree | 6b37d0208ae9fd9816e052572ab3496095cc88b6 /js/src/carousel.js | |
parent | 68f226750db03bc26ed5ead6bb074804a4f63853 (diff) |
Extract Component config functionality to a separate class (#33872)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/src/carousel.js')
-rw-r--r-- | js/src/carousel.js | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js index 3589f22067..e50894aa81 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -12,8 +12,7 @@ import { isRTL, isVisible, reflow, - triggerTransitionEnd, - typeCheckConfig + triggerTransitionEnd } from './util/index' import EventHandler from './dom/event-handler' import Manipulator from './dom/manipulator' @@ -95,7 +94,7 @@ const DefaultType = { class Carousel extends BaseComponent { constructor(element, config) { - super(element) + super(element, config) this._items = null this._interval = null @@ -105,7 +104,6 @@ class Carousel extends BaseComponent { this.touchTimeout = null this._swipeHelper = null - this._config = this._getConfig(config) this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element) this._addEventListeners() } @@ -115,6 +113,10 @@ class Carousel extends BaseComponent { return Default } + static get DefaultType() { + return DefaultType + } + static get NAME() { return NAME } @@ -205,16 +207,6 @@ class Carousel extends BaseComponent { } // Private - _getConfig(config) { - config = { - ...Default, - ...Manipulator.getDataAttributes(this._element), - ...(typeof config === 'object' ? config : {}) - } - typeCheckConfig(NAME, config, DefaultType) - return config - } - _addEventListeners() { if (this._config.keyboard) { EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event)) |