1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-13 17:14:04 +02:00

Reset carousel touch delta x to prevent click transformation in swipe (#28558)

This commit is contained in:
Johann-S
2019-03-27 13:37:04 +01:00
committed by XhmikosR
parent 3c3ed3ff05
commit 1752addadf
2 changed files with 6 additions and 2 deletions

View File

@@ -257,6 +257,8 @@ class Carousel {
const direction = absDeltax / this.touchDeltaX const direction = absDeltax / this.touchDeltaX
this.touchDeltaX = 0
// swipe left // swipe left
if (direction > 0) { if (direction > 0) {
this.prev() this.prev()

View File

@@ -1153,7 +1153,7 @@ $(function () {
} }
document.documentElement.ontouchstart = $.noop document.documentElement.ontouchstart = $.noop
assert.expect(3) assert.expect(4)
Simulator.setType('pointer') Simulator.setType('pointer')
var $styles = $(stylesCarousel).appendTo('head') var $styles = $(stylesCarousel).appendTo('head')
@@ -1182,6 +1182,7 @@ $(function () {
assert.ok(true, 'slid event fired') assert.ok(true, 'slid event fired')
assert.ok(!$item.hasClass('active')) assert.ok(!$item.hasClass('active'))
assert.ok(spy.called) assert.ok(spy.called)
assert.strictEqual(carousel.touchDeltaX, 0)
$styles.remove() $styles.remove()
delete document.documentElement.ontouchstart delete document.documentElement.ontouchstart
done() done()
@@ -1195,7 +1196,7 @@ $(function () {
}) })
QUnit.test('should allow swipeleft and call next with touch events', function (assert) { QUnit.test('should allow swipeleft and call next with touch events', function (assert) {
assert.expect(3) assert.expect(4)
clearPointerEvents() clearPointerEvents()
Simulator.setType('touch') Simulator.setType('touch')
document.documentElement.ontouchstart = $.noop document.documentElement.ontouchstart = $.noop
@@ -1225,6 +1226,7 @@ $(function () {
assert.ok(true, 'slid event fired') assert.ok(true, 'slid event fired')
assert.ok(!$item.hasClass('active')) assert.ok(!$item.hasClass('active'))
assert.ok(spy.called) assert.ok(spy.called)
assert.strictEqual(carousel.touchDeltaX, 0)
restorePointerEvents() restorePointerEvents()
delete document.documentElement.ontouchstart delete document.documentElement.ontouchstart
done() done()