我也没有使用 Jquery mobile,所以你可以试试这段代码,但它会响应但不是那么流畅
添加这个插件:
/* Cycle2 的滑动插件;版权所有 (c) 2012 M. Alsup; v20141007 */
!function(a){"use strict";a.event.special.swipe=a.event.special.swipe||{scrollSupressionThreshold:10,durationThreshold:1e3,horizontalDistanceThreshold:30,verticalDistanceThreshold:75,setup:function() {var b=a(this);b.bind("touchstart",function(c){function d(b){if(g){var c=b.originalEvent.touches?b.originalEvent.touches[0] :b;e={time:(new Date).getTime(),coords:[c.pageX,c.pageY]},Math.abs(g.coords[0]-e.coords[0])>a .event.special.swipe.scrollSupressionThreshold&&b.preventDefault()}}var e,f=c.originalEvent.touches?c.originalEvent.touches[0]:c,g={time:(new Date).getTime(), coords:[f.pageX,f.pageY],origin:a(c.target)};b.bind("touchmove",d).one("touchend",function(){b.unbind("touchmove" ,d),g&&e&&e.time-g.timea.event.special.swipe.horizontalDistanceThreshold&&Math.abs(g.coords[1]-e.coords[1])e.coords[0]?"swipeleft":"swiperight" ),g=e=void 0})})}},a.event.special.swipeleft=a.event.special.swipeleft||{setup:function(){a(this).bind("swipe", a.noop)}},a.event.special.swiperight=a.event.special.swiperi ght||a.event.special.swipeleft}(jQuery);
然后在你的 js 文件中添加这段代码:
$('#my-div div.slides').after('<nav id="pagination"></nav>');
$('#my-div div.slides').cycle(
{
fx: "scrollHorz",
slides: ".slide1",
timeout: 0,
speed: 200,
pager: "#pagination",
pagerTemplate: "<a href='#'>{{slideNum}}</a>",
pagerActiveClass: "active",
**swipe: true**
});