]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Reset carousel touch delta x to prevent click transformation in swipe (#28558)
authorJohann-S <johann.servoire@gmail.com>
Wed, 27 Mar 2019 12:37:04 +0000 (13:37 +0100)
committerXhmikosR <xhmikosr@gmail.com>
Wed, 27 Mar 2019 18:57:28 +0000 (20:57 +0200)
js/src/carousel.js
js/tests/unit/carousel.js

index 36176dd9c029ddcc2a55eb7cfe164a944a6196c9..8aeb9e038844c98863d77a5458c1d29544ced06f 100644 (file)
@@ -245,6 +245,8 @@ class Carousel {
 
     const direction = absDeltax / this.touchDeltaX
 
+    this.touchDeltaX = 0
+
     // swipe left
     if (direction > 0) {
       this.prev()
index 0d2a0f327104f2fef5b3cea35f98db20c79f92d7..f769f67b7890f671cad1d0c5dc605d7df851e910 100644 (file)
@@ -1118,7 +1118,7 @@ $(function () {
     }
 
     document.documentElement.ontouchstart = $.noop
-    assert.expect(3)
+    assert.expect(4)
     Simulator.setType('pointer')
 
     var $styles = $(stylesCarousel).appendTo('head')
@@ -1147,6 +1147,7 @@ $(function () {
       assert.ok(true, 'slid event fired')
       assert.ok(!$item.hasClass('active'))
       assert.ok(spy.called)
+      assert.strictEqual(carousel.touchDeltaX, 0)
       $styles.remove()
       delete document.documentElement.ontouchstart
       done()
@@ -1160,7 +1161,7 @@ $(function () {
   })
 
   QUnit.test('should allow swipeleft and call next with touch events', function (assert) {
-    assert.expect(3)
+    assert.expect(4)
     clearPointerEvents()
     Simulator.setType('touch')
     document.documentElement.ontouchstart = $.noop
@@ -1190,6 +1191,7 @@ $(function () {
       assert.ok(true, 'slid event fired')
       assert.ok(!$item.hasClass('active'))
       assert.ok(spy.called)
+      assert.strictEqual(carousel.touchDeltaX, 0)
       restorePointerEvents()
       delete document.documentElement.ontouchstart
       done()