// javascript document $(document).ready(function() { var w=window.innerwidth || document.documentelement.clientwidth || document.body.clientwidth; var h=window.innerheight || document.documentelement.clientheight || document.body.clientheight; //滑动动画 var indexprow=$(".about2 .box").width(); var indexprol=$(".about2 .box ul li").length; $(".about2 .box ul li").css({"width":indexprow/3}); $(".about2 .box ul").css({"width":indexprow*indexprol,"margin-left":-indexprow}); $(".about2 .box ul li").first().before($(".about2 .box ul li").last()); $(".about2 .box ul li").first().before($(".about2 .box ul li").last()); $(".about2 .box ul li").first().before($(".about2 .box ul li").last()); var mo=math.ceil(indexprol/3) $(".about2 .btn p span").text(mo) var bt=$(".about2 .btn p b").text() bt=1 //左滑动动画 function indexproleft(){ $(".about2 .box ul").animate({"margin-left":0},500,function(){ $(".about2 .box ul").css({"margin-left":-indexprow}); $(".about2 .box ul li").first().before($(".about2 .box ul li").last()); $(".about2 .box ul li").first().before($(".about2 .box ul li").last()); $(".about2 .box ul li").first().before($(".about2 .box ul li").last()); bt=bt-1 if(bt<1){ bt=mo } $(".about2 .btn p b").text(bt) }); } //右滑动动画 function indexproright(){ $(".about2 .box ul").animate({"margin-left":-2*indexprow},500,function(){ $(".about2 .box ul").css({"margin-left":-indexprow}); $(".about2 .box ul li").last().after($(".about2 .box ul li").first()); $(".about2 .box ul li").last().after($(".about2 .box ul li").first()); $(".about2 .box ul li").last().after($(".about2 .box ul li").first()); ++bt if(bt>mo){ bt=1 } $(".about2 .btn p b").text(bt) }); } if($(window).width()<=766){ $(".about2 .box ul li").css({"width":indexprow}); var indexprol=$(".about2 .box ul li").length; $(".about2 .box ul li").last().after($(".about2 .box ul li").first()); $(".about2 .box ul li").last().after($(".about2 .box ul li").first()); var mo=indexprol $(".about2 .btn p span").text(mo) //左滑动动画 function indexproleft(){ $(".about2 .box ul").animate({"margin-left":0},500,function(){ $(".about2 .box ul").css({"margin-left":-indexprow}); $(".about2 .box ul li").first().before($(".about2 .box ul li").last()); bt=bt-1 if(bt<1){ bt=mo } $(".about2 .btn p b").text(bt) }); } //右滑动动画 function indexproright(){ $(".about2 .box ul").animate({"margin-left":-2*indexprow},500,function(){ $(".about2 .box ul").css({"margin-left":-indexprow}); $(".about2 .box ul li").last().after($(".about2 .box ul li").first()); ++bt if(bt>mo){ bt=1 } $(".about2 .btn p b").text(bt) }); } } $(".about2 .box ul").hammer().on("swiperight",function(){ indexproleft(); }); $(".about2 .box ul").hammer().on("swipeleft",function(){ indexproright(); }); $(".about2 .btn .left").hammer().on("tap",function(){ indexproleft(); }); $(".about2 .btn .right").hammer().on("tap",function(){ indexproright(); }); });