Bootstrap_让Bootstrap轮播插件carousel支持左右滑动手势的三种方法

Bootstrap 的 carousel.js 插件并没有支持手势。

3种解决方案 :

jQuery Mobile (http://jquerymobile.com/download/)
 $("#carousel-generic").swipeleft(function() {
  $(this).carousel('next');
 });

 $("#carousel-generic").swiperight(function() {
  $(this).carousel('prev');
 });
TouchSwipe jQuery plugin (https://github.com/mattbryson/TouchSwipe-Jquery-Plugin)
 $("#carousel-generic").swipe({
  swipeLeft: function() { $(this).carousel('next'); },
  swipeRight: function() { $(this).carousel('prev'); },
 });
hammer.js (http://eightmedia.github.io/hammer.js/) + 
jquery.hammer.js (https://github.com/EightMedia/jquery.hammer.js)
 $('#carousel-generic').hammer().on('swipeleft', function(){
  $(this).carousel('next');
 });

 $('#carousel-generic').hammer().on('swiperight', function(){
  $(this).carousel('prev');
 });

hammer.js 官网:http://hammerjs.github.io/ ,版本基于v2.0.4:

var carousel = new Hammer(document.getElementById("carousel"));
            carousel.on('swipeleft', function(){
                $(this).carousel('next');
            });

            carousel.on('swiperight', function(){
                $(this).carousel('prev');
            });
原文地址:https://www.cnblogs.com/gisblogs/p/4975303.html