mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-13 00:54:04 +02:00
build
This commit is contained in:
26
js/dist/carousel.js
vendored
26
js/dist/carousel.js
vendored
@@ -28,6 +28,7 @@ var Carousel = function ($) {
|
||||
var TRANSITION_DURATION = 600;
|
||||
var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
|
||||
var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
|
||||
var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
|
||||
|
||||
var Default = {
|
||||
interval: 5000,
|
||||
@@ -58,6 +59,7 @@ var Carousel = function ($) {
|
||||
KEYDOWN: 'keydown' + EVENT_KEY,
|
||||
MOUSEENTER: 'mouseenter' + EVENT_KEY,
|
||||
MOUSELEAVE: 'mouseleave' + EVENT_KEY,
|
||||
TOUCHEND: 'touchend' + EVENT_KEY,
|
||||
LOAD_DATA_API: 'load' + EVENT_KEY + DATA_API_KEY,
|
||||
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
|
||||
};
|
||||
@@ -100,6 +102,8 @@ var Carousel = function ($) {
|
||||
this._isPaused = false;
|
||||
this._isSliding = false;
|
||||
|
||||
this.touchTimeout = null;
|
||||
|
||||
this._config = this._getConfig(config);
|
||||
this._element = $(element)[0];
|
||||
this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0];
|
||||
@@ -219,12 +223,30 @@ var Carousel = function ($) {
|
||||
});
|
||||
}
|
||||
|
||||
if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) {
|
||||
if (this._config.pause === 'hover') {
|
||||
$(this._element).on(Event.MOUSEENTER, function (event) {
|
||||
return _this2.pause(event);
|
||||
}).on(Event.MOUSELEAVE, function (event) {
|
||||
return _this2.cycle(event);
|
||||
});
|
||||
if ('ontouchstart' in document.documentElement) {
|
||||
// if it's a touch-enabled device, mouseenter/leave are fired as
|
||||
// part of the mouse compatibility events on first tap - the carousel
|
||||
// would stop cycling until user tapped out of it;
|
||||
// here, we listen for touchend, explicitly pause the carousel
|
||||
// (as if it's the second time we tap on it, mouseenter compat event
|
||||
// is NOT fired) and after a timeout (to allow for mouse compatibility
|
||||
// events to fire) we explicitly restart cycling
|
||||
$(this._element).on(Event.TOUCHEND, function () {
|
||||
_this2.pause();
|
||||
if (_this2.touchTimeout) {
|
||||
clearTimeout(_this2.touchTimeout);
|
||||
}
|
||||
_this2.touchTimeout = setTimeout(function (event) {
|
||||
return _this2.cycle(event);
|
||||
}, TOUCHEVENT_COMPAT_WAIT + _this2._config.interval);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -488,4 +510,4 @@ var Carousel = function ($) {
|
||||
|
||||
return Carousel;
|
||||
}(jQuery);
|
||||
//# sourceMappingURL=carousel.js.map
|
||||
//# sourceMappingURL=carousel.js.map
|
Reference in New Issue
Block a user