jQuery(".carousel").on("touchstart", function(event){ var xClick = event.originalEvent.touches[0].pageX; jQuery(this).one("touchmove", function(event){ var xMove = event.originalEvent.touches[0].pageX; if( Math.floor(xClick - xMove) > 5 ){ jQuery(this).carousel('next'); } else if( Math.floor(xClick - xMove) < -5 ){ jQuery(this).carousel('prev'); } }); jQuery(".carousel").on("touchend", function(){ jQuery(this).off("touchmove"); }); });
Note: No need of any JS library besides native jQuery only.