`

jquery三种支持手机触屏的插件库

 
阅读更多
http://my.oschina.net/u/2395167/blog/522582
因为最近开发的项目涉及到移动设备上的 HTML5 开发,其中需要实现轮播效果。然后最快捷的方式,你知道(Bootstrap),然后原生的 Bootstrap 的 carousel.js 插件并没有支持手势。

如下有三种方式:

1、下载jquerymobile库文件,导入js文件:

调用:swipeleft 和  swiperight 或 swipe  事件

2、使用TouchSwipe jQuery plugin 插件  地址:https://github.com/mattbryson/TouchSwipe-Jquery-Plugin

使用方法:
$("#carousel-generic").swipe({
  swipeLeft: function() { $(this).carousel('next'); },
  swipeRight: function() { $(this).carousel('prev'); },
 });

3、使用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');
 });
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics