mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-30 22:52:24 +01:00
Carousel: move carouselInterface
inside jqueryInterface
This commit is contained in:
parent
13042d25ca
commit
eb8d5b43ce
@ -432,36 +432,32 @@ class Carousel extends BaseComponent {
|
||||
}
|
||||
|
||||
// Static
|
||||
static carouselInterface(element, config) {
|
||||
const data = Carousel.getOrCreateInstance(element, config)
|
||||
|
||||
let { _config } = data
|
||||
if (typeof config === 'object') {
|
||||
_config = {
|
||||
..._config,
|
||||
...config
|
||||
}
|
||||
}
|
||||
|
||||
const action = typeof config === 'string' ? config : _config.slide
|
||||
|
||||
if (typeof config === 'number') {
|
||||
data.to(config)
|
||||
} else if (typeof action === 'string') {
|
||||
if (typeof data[action] === 'undefined') {
|
||||
throw new TypeError(`No method named "${action}"`)
|
||||
}
|
||||
|
||||
data[action]()
|
||||
} else if (_config.interval && _config.ride) {
|
||||
data.pause()
|
||||
data.cycle()
|
||||
}
|
||||
}
|
||||
|
||||
static jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
Carousel.carouselInterface(this, config)
|
||||
const data = Carousel.getOrCreateInstance(this, config)
|
||||
|
||||
let { _config } = data
|
||||
if (typeof config === 'object') {
|
||||
_config = {
|
||||
..._config,
|
||||
...config
|
||||
}
|
||||
}
|
||||
|
||||
const action = typeof config === 'string' ? config : _config.slide
|
||||
|
||||
if (typeof config === 'number') {
|
||||
data.to(config)
|
||||
} else if (typeof action === 'string') {
|
||||
if (typeof data[action] === 'undefined') {
|
||||
throw new TypeError(`No method named "${action}"`)
|
||||
}
|
||||
|
||||
data[action]()
|
||||
} else if (_config.interval && _config.ride) {
|
||||
data.pause()
|
||||
data.cycle()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user