Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Otto <markdotto@gmail.com>2017-04-22 09:58:09 +0300
committerMark Otto <markdotto@gmail.com>2017-04-22 09:58:09 +0300
commitba312c20a5ceca42117dd53303bafda485d8facd (patch)
tree2d185875a0ac2b73d34a8187e7d4c696b7625eec /js/dist/carousel.js
parent638b97f19c4df6f51475f8088555e3eefd2b986f (diff)
build
Diffstat (limited to 'js/dist/carousel.js')
-rw-r--r--js/dist/carousel.js26
1 files changed, 24 insertions, 2 deletions
diff --git a/js/dist/carousel.js b/js/dist/carousel.js
index 77d6e80d90..18186bc13a 100644
--- a/js/dist/carousel.js
+++ b/js/dist/carousel.js
@@ -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 \ No newline at end of file