function imgshow(imglist,imgshow,number,width,direction){ var objul = imglist.find("ul"); var objli = imglist.find("li"); var objcimg = objli.children("img"); var objimg = imgshow.find("img"); var objup = imglist.find(".prev"); var objdown = imglist.find(".next"); if(direction == "margin-left"){ objul.width(objli.length*width*2); }else{ objul.width(objli.length*width*2); } objli.click(function(){ prosliderun(objli.index(this)); }) objup.click(function(){ prosliderun(objli.index(objul.children("li.cur"))-1); }) objdown.click(function(){ prosliderun(objli.index(objul.children("li.cur"))+1); }) // touch.on(objul, "swipeleft", function(){ // objup.click(function(){ // prosliderun(objli.index(objul.children("li.cur"))-1); // }) // }) // touch.on(objul, "swiperight", function(){ // objdown.click(function(){ // prosliderun(objli.index(objul.children("li.cur"))+1); // }) // }) function prosliderun(n){ if(n>=objli.length){n=objli.length-1;return false;} if(n<0){n=0;return false;} if(n<=1){ if(direction == "margin-left"){ objul.animate({"margin-left":0},300); }else{ objul.animate({"margin-left":0},300); }; }else if(n>=objli.length-(number-1) && objli.length-(number-1)>0){ if(direction == "margin-left"){ objul.animate({"margin-left":-(objli.length-number)*width+"px"},300); }else{ objul.animate({"margin-left":-(objli.length-number)*width+"px"},300); }; }else if(objli.length-(number-1)>0){ if(direction == "margin-left"){ objul.animate({"margin-left":-(n-1)*width+"px"},300); }else{ objul.animate({"margin-left":-(n-1)*width+"px"},300); }; } objli.removeclass("cur").eq(n).addclass("cur"); objimg.fadeto(300,1,function(){ // objimg.attr("src",""); // objimg.attr("src",objli.eq(n).children("img").attr("data-img")); // objimg.fadeto(300,1,function(){ // objimg.attr("src",objli.eq(n).children("img").attr("data-img")); // objimg.siblings("p").html(objli.eq(n).children("img").attr("data-title")); // }); var url1 = site_url +'floor/pro_videoimg'; var id = objli.eq(n).attr("data-id"); imgshow.load(url1+'/'+id); }) }; prosliderun(0); }