From 1ff46a154cf8d790a593096bec04d152d8fad39f Mon Sep 17 00:00:00 2001 From: Omri Cohen Date: Tue, 20 Jun 2017 13:35:52 +0300 Subject: [PATCH 1/2] Update jquery.bcSwipe.js changed to use jquery events --- jquery.bcSwipe.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/jquery.bcSwipe.js b/jquery.bcSwipe.js index 216a1e1..e81a453 100644 --- a/jquery.bcSwipe.js +++ b/jquery.bcSwipe.js @@ -12,26 +12,24 @@ if (settings) { $.extend(config, settings); } - this.each(function() { var stillMoving = false; var start; - if ('ontouchstart' in document.documentElement) { - this.addEventListener('touchstart', onTouchStart, false); - } + $(this).on('touchstart', onTouchStart); function onTouchStart(e) { - if (e.touches.length == 1) { - start = e.touches[0].pageX; + + if (e.originalEvent.touches.length == 1) { + start = e.originalEvent.touches[0].pageX; stillMoving = true; - this.addEventListener('touchmove', onTouchMove, false); + $(this).on('touchmove', onTouchMove); } } function onTouchMove(e) { if (stillMoving) { - var x = e.touches[0].pageX; + var x = e.originalEvent.touches[0].pageX; var difference = start - x; if (Math.abs(difference) >= config.threshold) { cancelTouch(); @@ -46,7 +44,7 @@ } function cancelTouch() { - this.removeEventListener('touchmove', onTouchMove); + $(this).off('touchmove'); start = null; stillMoving = false; } From 5f454ecac24615610056e2669c4d9eac158b49af Mon Sep 17 00:00:00 2001 From: Omri Cohen Date: Tue, 19 Sep 2017 20:18:07 -0700 Subject: [PATCH 2/2] Update jquery.bcSwipe.min.js --- jquery.bcSwipe.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.bcSwipe.min.js b/jquery.bcSwipe.min.js index e8ef802..b924e54 100644 --- a/jquery.bcSwipe.min.js +++ b/jquery.bcSwipe.min.js @@ -1,2 +1,2 @@ /*! Bootstrap Carousel Swipe jQuery plugin v1.1 | https://github.com/maaaaark/bcSwipe | MIT License */ -!function(t){t.fn.bcSwipe=function(e){var n={threshold:50};return e&&t.extend(n,e),this.each(function(){function e(t){1==t.touches.length&&(u=t.touches[0].pageX,c=!0,this.addEventListener("touchmove",o,!1))}function o(e){if(c){var o=e.touches[0].pageX,i=u-o;Math.abs(i)>=n.threshold&&(h(),t(this).carousel(i>0?"next":"prev"))}}function h(){this.removeEventListener("touchmove",o),u=null,c=!1}var u,c=!1;"ontouchstart"in document.documentElement&&this.addEventListener("touchstart",e,!1)}),this}}(jQuery); +!function(t){t.fn.bcSwipe=function(n){var o={threshold:50};return n&&t.extend(o,n),this.each(function(){function n(n){if(h){var u=n.originalEvent.touches[0].pageX,c=i-u;Math.abs(c)>=o.threshold&&(e(),c>0?t(this).carousel("next"):t(this).carousel("prev"))}}function e(){t(this).off("touchmove"),i=null,h=!1}var i,h=!1;t(this).on("touchstart",function(o){1==o.originalEvent.touches.length&&(i=o.originalEvent.touches[0].pageX,h=!0,t(this).on("touchmove",n))})}),this}}(jQuery);