mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-06 04:08:22 +01:00
Fix Carousel's touch option to not add touch listeners when set to false (#28046)
This commit is contained in:
parent
3d350c3b34
commit
d51ee0dcf1
@ -268,8 +268,10 @@ class Carousel {
|
|||||||
.on(Event.MOUSELEAVE, (event) => this.cycle(event))
|
.on(Event.MOUSELEAVE, (event) => this.cycle(event))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._config.touch) {
|
||||||
this._addTouchEventListeners()
|
this._addTouchEventListeners()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_addTouchEventListeners() {
|
_addTouchEventListeners() {
|
||||||
if (!this._touchSupported) {
|
if (!this._touchSupported) {
|
||||||
|
@ -948,7 +948,7 @@ $(function () {
|
|||||||
$textArea.trigger(eventKeyDown)
|
$textArea.trigger(eventKeyDown)
|
||||||
})
|
})
|
||||||
|
|
||||||
QUnit.test('Should not go to the next item when the carousel is not visible', function (assert) {
|
QUnit.test('should not go to the next item when the carousel is not visible', function (assert) {
|
||||||
assert.expect(2)
|
assert.expect(2)
|
||||||
var done = assert.async()
|
var done = assert.async()
|
||||||
var html = '<div id="myCarousel" class="carousel slide" data-interval="50" style="display: none;">' +
|
var html = '<div id="myCarousel" class="carousel slide" data-interval="50" style="display: none;">' +
|
||||||
@ -985,7 +985,7 @@ $(function () {
|
|||||||
}, 80)
|
}, 80)
|
||||||
})
|
})
|
||||||
|
|
||||||
QUnit.test('Should not go to the next item when the parent of the carousel is not visible', function (assert) {
|
QUnit.test('should not go to the next item when the parent of the carousel is not visible', function (assert) {
|
||||||
assert.expect(2)
|
assert.expect(2)
|
||||||
var done = assert.async()
|
var done = assert.async()
|
||||||
var html = '<div id="parent" style="display: none;">' +
|
var html = '<div id="parent" style="display: none;">' +
|
||||||
@ -1317,4 +1317,17 @@ $(function () {
|
|||||||
done()
|
done()
|
||||||
}, 5)
|
}, 5)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
QUnit.test('should not add touch event listeners when touch option set to false', function (assert) {
|
||||||
|
assert.expect(1)
|
||||||
|
|
||||||
|
var spy = sinon.spy(Carousel.prototype, '_addTouchEventListeners')
|
||||||
|
var $carousel = $('<div class="carousel" data-ride="carousel" data-touch="false"></div>')
|
||||||
|
|
||||||
|
$carousel.appendTo('#qunit-fixture')
|
||||||
|
$carousel.bootstrapCarousel()
|
||||||
|
|
||||||
|
assert.strictEqual(spy.called, false)
|
||||||
|
spy.restore()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user