mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-13 00:54:04 +02:00
dist
This commit is contained in:
35
js/dist/carousel.js
vendored
35
js/dist/carousel.js
vendored
@@ -1,4 +1,6 @@
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
@@ -28,7 +30,6 @@ var Carousel = function ($) {
|
||||
|
||||
var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
|
||||
|
||||
var MILLISECONDS_MULTIPLIER = 1000;
|
||||
var Default = {
|
||||
interval: 5000,
|
||||
keyboard: true,
|
||||
@@ -98,7 +99,6 @@ var Carousel = function ($) {
|
||||
this._config = this._getConfig(config);
|
||||
this._element = $(element)[0];
|
||||
this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0];
|
||||
this._transitionDuration = this._getTransitionDuration();
|
||||
|
||||
this._addEventListeners();
|
||||
} // Getters
|
||||
@@ -132,7 +132,7 @@ var Carousel = function ($) {
|
||||
this._isPaused = true;
|
||||
}
|
||||
|
||||
if ($(this._element).find(Selector.NEXT_PREV)[0] && Util.supportsTransitionEnd()) {
|
||||
if ($(this._element).find(Selector.NEXT_PREV)[0]) {
|
||||
Util.triggerTransitionEnd(this._element);
|
||||
this.cycle(true);
|
||||
}
|
||||
@@ -200,25 +200,11 @@ var Carousel = function ($) {
|
||||
|
||||
|
||||
_proto._getConfig = function _getConfig(config) {
|
||||
config = _extends({}, Default, config);
|
||||
config = _objectSpread({}, Default, config);
|
||||
Util.typeCheckConfig(NAME, config, DefaultType);
|
||||
return config;
|
||||
};
|
||||
|
||||
_proto._getTransitionDuration = function _getTransitionDuration() {
|
||||
// Get transition-duration of first element in the carousel
|
||||
var transitionDuration = $(this._element).find(Selector.ITEM).css('transition-duration'); // Return 0 carousel item is not found
|
||||
|
||||
if (!transitionDuration) {
|
||||
return 0;
|
||||
} // If multiple durations are defined, take the first
|
||||
|
||||
|
||||
transitionDuration = transitionDuration.split(',')[0]; // Multiply by 1000 if transition-duration is defined in seconds
|
||||
|
||||
return transitionDuration.indexOf('ms') > -1 ? parseFloat(transitionDuration) : parseFloat(transitionDuration) * MILLISECONDS_MULTIPLIER;
|
||||
};
|
||||
|
||||
_proto._addEventListeners = function _addEventListeners() {
|
||||
var _this2 = this;
|
||||
|
||||
@@ -385,11 +371,12 @@ var Carousel = function ($) {
|
||||
to: nextElementIndex
|
||||
});
|
||||
|
||||
if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {
|
||||
if ($(this._element).hasClass(ClassName.SLIDE)) {
|
||||
$(nextElement).addClass(orderClassName);
|
||||
Util.reflow(nextElement);
|
||||
$(activeElement).addClass(directionalClassName);
|
||||
$(nextElement).addClass(directionalClassName);
|
||||
var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
|
||||
$(activeElement).one(Util.TRANSITION_END, function () {
|
||||
$(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName.ACTIVE);
|
||||
$(activeElement).removeClass(ClassName.ACTIVE + " " + orderClassName + " " + directionalClassName);
|
||||
@@ -397,7 +384,7 @@ var Carousel = function ($) {
|
||||
setTimeout(function () {
|
||||
return $(_this3._element).trigger(slidEvent);
|
||||
}, 0);
|
||||
}).emulateTransitionEnd(this._transitionDuration);
|
||||
}).emulateTransitionEnd(transitionDuration);
|
||||
} else {
|
||||
$(activeElement).removeClass(ClassName.ACTIVE);
|
||||
$(nextElement).addClass(ClassName.ACTIVE);
|
||||
@@ -415,10 +402,10 @@ var Carousel = function ($) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data(DATA_KEY);
|
||||
|
||||
var _config = _extends({}, Default, $(this).data());
|
||||
var _config = _objectSpread({}, Default, $(this).data());
|
||||
|
||||
if (typeof config === 'object') {
|
||||
_config = _extends({}, _config, config);
|
||||
_config = _objectSpread({}, _config, config);
|
||||
}
|
||||
|
||||
var action = typeof config === 'string' ? config : _config.slide;
|
||||
@@ -456,7 +443,7 @@ var Carousel = function ($) {
|
||||
return;
|
||||
}
|
||||
|
||||
var config = _extends({}, $(target).data(), $(this).data());
|
||||
var config = _objectSpread({}, $(target).data(), $(this).data());
|
||||
|
||||
var slideIndex = this.getAttribute('data-slide-to');
|
||||
|
||||
|
Reference in New Issue
Block a user