mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-17 09:52:29 +01:00
Merge pull request #14626 from twbs/carousel-pause-hover-non-mobile
Only enable `pause: hover` for non-touch browsers
This commit is contained in:
commit
b702889613
@ -23,7 +23,7 @@
|
|||||||
this.$active =
|
this.$active =
|
||||||
this.$items = null
|
this.$items = null
|
||||||
|
|
||||||
this.options.pause == 'hover' && this.$element
|
this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element
|
||||||
.on('mouseenter.bs.carousel', $.proxy(this.pause, this))
|
.on('mouseenter.bs.carousel', $.proxy(this.pause, this))
|
||||||
.on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
|
.on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
|
||||||
}
|
}
|
||||||
|
@ -398,4 +398,26 @@ $(function () {
|
|||||||
|
|
||||||
strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('should only add mouseenter and mouseleave listeners when not on mobile', function () {
|
||||||
|
var isMobile = 'ontouchstart' in document.documentElement
|
||||||
|
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-pause="hover">'
|
||||||
|
+ '<div class="carousel-inner">'
|
||||||
|
+ '<div id="first" class="item active">'
|
||||||
|
+ '<img alt="">'
|
||||||
|
+ '</div>'
|
||||||
|
+ '<div id="second" class="item">'
|
||||||
|
+ '<img alt="">'
|
||||||
|
+ '</div>'
|
||||||
|
+ '<div id="third" class="item">'
|
||||||
|
+ '<img alt="">'
|
||||||
|
+ '</div>'
|
||||||
|
+ '</div>'
|
||||||
|
+ '</div>'
|
||||||
|
var $template = $(templateHTML).bootstrapCarousel()
|
||||||
|
|
||||||
|
$.each(['mouseover', 'mouseout'], function (i, type) {
|
||||||
|
strictEqual(type in $._data($template[0], 'events'), !isMobile, 'does' + (isMobile ? ' not' : '') + ' listen for ' + type + ' events')
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user