// javascript document $(function(){ var w=window.innerwidth || document.documentelement.clientwidth || document.body.clientwidth; var h=window.innerheight || document.documentelement.clientheight || document.body.clientheight; $(".indexbox").css({"height":h}); $("body").css({"position":"fixed","top":0,"left":0}); //banner轮播 var banner_l=$(".banner ul li").length;//banner轮播_start $(".banner ul li").css({"width":w}); $(".banner ul li").eq(0).css({"left":0}); var k=0; function lunbo(){//自动轮播 $(".banner ul li").css({"left":"100%"}); $(".banner ul li").eq(k).css({"left":0}); $(".banner ul li").eq(k).animate({left:"-100%"},500); if(k0){ k=k-1; }else{ k=banner_l-1; } $(".banner ul li").eq(k).stop(true,true).animate({left:0},500); } //banner滑动 $(".banner").hammer().on("swipeleft",function(){ //防止快速滑动产生的错乱 if(!$(".banner ul li").is(":animated")){ bannerleft(); } }); $(".banner").hammer().on("swiperight",function(){ if(!$(".banner ul li").is(":animated")){ bannerright(); } }); //向下按钮动画 function scrollbtn(){ $(".scrollbottombtn span").css({"bottom":30,"opacity":1}); $(".scrollbottombtn").each(function(){ $(this).find("span").eq(0).animate({"bottom":0,"opacity":0},400); $(this).find("span").eq(1).delay(120).animate({"bottom":0,"opacity":0},400); $(this).find("span").eq(2).delay(240).animate({"bottom":0,"opacity":0},400); }); } var time=setinterval(scrollbtn,2000); $(".indexrightnav").css({"top":1.5*h}); var isff = navigator.useragent.tolowercase().indexof("firefox")>=0; var upordown = ""; var s=0; var sl=$(".indexbox").length-1; //滚动事件>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>start //判断是否为火狐 if (isff) { document.addeventlistener('dommousescroll', function (e) { var e = e || window.event; upordown = e.detail < 0 ? "up" : "down"; //console.log(upordown) scrollfun(upordown); }); } else { document.onmousewheel = function (e) { var e = e || window.event; upordown = e.wheeldelta > 0 ? "up" : "down"; //console.log(upordown); scrollfun(upordown); } } //滑动事件 //屏蔽手机自带滑动效果 document.queryselector('body').addeventlistener('touchmove', function (ev) { event.preventdefault(); }); var banner_start_x,banner_start_y,banner_end_x,banner_end_y; $(".indexbox").on("touchstart",function(e){ banner_start_x = e.originalevent.targettouches[0].pagex; banner_start_y = e.originalevent.targettouches[0].pagey; }); $(".indexbox").on("touchmove",function(e){ banner_end_x = e.originalevent.targettouches[0].pagex; banner_end_y = e.originalevent.targettouches[0].pagey; }); $(".indexbox").on("touchend",function(){ var move_x=banner_end_x-banner_start_x; var move_y=banner_end_y-banner_start_y; if((move_y<0)&&(-move_y>30)){ //console.log("下滑"); scrollfun("down"); } if(move_y>0&&(move_y>30)){ //console.log("上滑"); scrollfun("up"); } }); //向下滚动动画 function scrollhandown(s){ $("body").animate({"top":-h*s},600); $("body").animate({"top":-h*s+30},160); $("body").animate({"top":-h*s},160); $("body").animate({"top":-h*s+10},100); $("body").animate({"top":-h*s},100); if(s!=0){ $(".indexrightnav").delay(200).animate({"top":(s+0.5)*h},500,function(){ $(".indexrightnav dl dd").removeclass("active").eq(s).addclass("active"); }); } } //向上滚动动画 function scrollhanup(s){ $("body").animate({"top":-h*s},600); $("body").animate({"top":-h*s-30},160); $("body").animate({"top":-h*s},160); $("body").animate({"top":-h*s-10},100); $("body").animate({"top":-h*s},100); if(s!=0){ $(".indexrightnav").delay(200).animate({"top":(s+0.5)*h},500,function(){ $(".indexrightnav dl dd").removeclass("active").eq(s).addclass("active"); }); } } function scrollfun(ore){ if(ore=="down"){ if(!$("body").is(":animated")){ if(s0){ s--; scrollhanup(s); } } } } //滚动事件>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>end //鼠标经过右边按钮事件 $(".indexrightnav dl dd").mouseenter(function(){ var mi=$(this).index(); $(".indexrightnav dl dd").removeclass("active").eq(mi).addclass("active"); }).mouseleave(function(){ $(".indexrightnav dl dd").removeclass("active").eq(s).addclass("active"); }); //点击右边按钮事件 $(".indexrightnav dl dd").click(function(){ var righti=$(this).index(); if(righti>s){ scrollhandown(righti); } if(righti