@@ -8,16 +8,14 @@ if (typeof jQuery === 'undefined') {
8
8
throw new Error ( 'Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.' )
9
9
}
10
10
11
- + function ( $ ) {
11
+ ( function ( $ ) {
12
12
var version = $ . fn . jquery . split ( ' ' ) [ 0 ] . split ( '.' )
13
13
if ( ( version [ 0 ] < 2 && version [ 1 ] < 9 ) || ( version [ 0 ] == 1 && version [ 1 ] == 9 && version [ 2 ] < 1 ) || ( version [ 0 ] >= 4 ) ) {
14
14
throw new Error ( 'Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0' )
15
15
}
16
- } ( jQuery ) ;
17
-
18
-
19
- + function ( ) {
16
+ } ) ( jQuery ) ;
20
17
18
+ ( function ( ) {
21
19
var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
22
20
23
21
var _createClass = function ( ) { 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 ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
@@ -551,6 +549,7 @@ var Carousel = function ($) {
551
549
var TRANSITION_DURATION = 600 ;
552
550
var ARROW_LEFT_KEYCODE = 37 ; // KeyboardEvent.which value for left arrow key
553
551
var ARROW_RIGHT_KEYCODE = 39 ; // KeyboardEvent.which value for right arrow key
552
+ var TOUCHEVENT_COMPAT_WAIT = 500 ; // Time for mouse compat events to fire after touch
554
553
555
554
var Default = {
556
555
interval : 5000 ,
@@ -581,6 +580,7 @@ var Carousel = function ($) {
581
580
KEYDOWN : 'keydown' + EVENT_KEY ,
582
581
MOUSEENTER : 'mouseenter' + EVENT_KEY ,
583
582
MOUSELEAVE : 'mouseleave' + EVENT_KEY ,
583
+ TOUCHEND : 'touchend' + EVENT_KEY ,
584
584
LOAD_DATA_API : 'load' + EVENT_KEY + DATA_API_KEY ,
585
585
CLICK_DATA_API : 'click' + EVENT_KEY + DATA_API_KEY
586
586
} ;
@@ -623,6 +623,8 @@ var Carousel = function ($) {
623
623
this . _isPaused = false ;
624
624
this . _isSliding = false ;
625
625
626
+ this . touchTimeout = null ;
627
+
626
628
this . _config = this . _getConfig ( config ) ;
627
629
this . _element = $ ( element ) [ 0 ] ;
628
630
this . _indicatorsElement = $ ( this . _element ) . find ( Selector . INDICATORS ) [ 0 ] ;
@@ -742,12 +744,30 @@ var Carousel = function ($) {
742
744
} ) ;
743
745
}
744
746
745
- if ( this . _config . pause === 'hover' && ! ( 'ontouchstart' in document . documentElement ) ) {
747
+ if ( this . _config . pause === 'hover' ) {
746
748
$ ( this . _element ) . on ( Event . MOUSEENTER , function ( event ) {
747
749
return _this4 . pause ( event ) ;
748
750
} ) . on ( Event . MOUSELEAVE , function ( event ) {
749
751
return _this4 . cycle ( event ) ;
750
752
} ) ;
753
+ if ( 'ontouchstart' in document . documentElement ) {
754
+ // if it's a touch-enabled device, mouseenter/leave are fired as
755
+ // part of the mouse compatibility events on first tap - the carousel
756
+ // would stop cycling until user tapped out of it;
757
+ // here, we listen for touchend, explicitly pause the carousel
758
+ // (as if it's the second time we tap on it, mouseenter compat event
759
+ // is NOT fired) and after a timeout (to allow for mouse compatibility
760
+ // events to fire) we explicitly restart cycling
761
+ $ ( this . _element ) . on ( Event . TOUCHEND , function ( ) {
762
+ _this4 . pause ( ) ;
763
+ if ( _this4 . touchTimeout ) {
764
+ clearTimeout ( _this4 . touchTimeout ) ;
765
+ }
766
+ _this4 . touchTimeout = setTimeout ( function ( event ) {
767
+ return _this4 . cycle ( event ) ;
768
+ } , TOUCHEVENT_COMPAT_WAIT + _this4 . _config . interval ) ;
769
+ } ) ;
770
+ }
751
771
}
752
772
} ;
753
773
@@ -1463,7 +1483,7 @@ var Dropdown = function ($) {
1463
1483
// only needed because of broken event delegation on iOS
1464
1484
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
1465
1485
if ( 'ontouchstart' in document . documentElement && ! $ ( parent ) . closest ( Selector . NAVBAR_NAV ) . length ) {
1466
- $ ( 'body' ) . children ( ) . on ( 'mouseover' , '*' , $ . noop ) ;
1486
+ $ ( 'body' ) . children ( ) . on ( 'mouseover' , null , $ . noop ) ;
1467
1487
}
1468
1488
1469
1489
this . focus ( ) ;
@@ -1537,7 +1557,7 @@ var Dropdown = function ($) {
1537
1557
// if this is a touch-enabled device we remove the extra
1538
1558
// empty mouseover listeners we added for iOS support
1539
1559
if ( 'ontouchstart' in document . documentElement ) {
1540
- $ ( 'body' ) . children ( ) . off ( 'mouseover' , '*' , $ . noop ) ;
1560
+ $ ( 'body' ) . children ( ) . off ( 'mouseover' , null , $ . noop ) ;
1541
1561
}
1542
1562
1543
1563
toggles [ i ] . setAttribute ( 'aria-expanded' , 'false' ) ;
@@ -3041,6 +3061,14 @@ var Tooltip = function ($) {
3041
3061
3042
3062
$ ( tip ) . addClass ( ClassName . SHOW ) ;
3043
3063
3064
+ // if this is a touch-enabled device we add extra
3065
+ // empty mouseover listeners to the body's immediate children;
3066
+ // only needed because of broken event delegation on iOS
3067
+ // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
3068
+ if ( 'ontouchstart' in document . documentElement ) {
3069
+ $ ( 'body' ) . children ( ) . on ( 'mouseover' , null , $ . noop ) ;
3070
+ }
3071
+
3044
3072
var complete = function complete ( ) {
3045
3073
var prevHoverState = _this23 . _hoverState ;
3046
3074
_this23 . _hoverState = null ;
@@ -3089,6 +3117,12 @@ var Tooltip = function ($) {
3089
3117
3090
3118
$ ( tip ) . removeClass ( ClassName . SHOW ) ;
3091
3119
3120
+ // if this is a touch-enabled device we remove the extra
3121
+ // empty mouseover listeners we added for iOS support
3122
+ if ( 'ontouchstart' in document . documentElement ) {
3123
+ $ ( 'body' ) . children ( ) . off ( 'mouseover' , null , $ . noop ) ;
3124
+ }
3125
+
3092
3126
this . _activeTrigger [ Trigger . CLICK ] = false ;
3093
3127
this . _activeTrigger [ Trigger . FOCUS ] = false ;
3094
3128
this . _activeTrigger [ Trigger . HOVER ] = false ;
@@ -3593,4 +3627,5 @@ var Popover = function ($) {
3593
3627
return Popover ;
3594
3628
} ( jQuery ) ;
3595
3629
3596
- } ( ) ;
3630
+
3631
+ } ) ( )
0 commit comments