1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- $(function(){
- $('.index_tt .banner_txt').eq(0).show().siblings().hide();
- var $ct=$('.banner_box ul'),
- $items=$ct.children(),
- $pre=$('.index_pre'),
- $next=$('.banner_next'),
- imgCount=$items.length,
- imgWidth=$items.width();
- $ct.append($items.first().clone());
- $ct.prepend($items.last().clone());
- var newCount=$ct.children().length;
- $ct.css({marginLeft:0-imgWidth,width:newCount*imgWidth});
- $next.on('click',function(){
- playnext();
- })
- $pre.on('click',function(){
- playpre();
- })
- var curidx =0;
- var mov = 1;
- function playnext(){
- $ct.animate({marginLeft:'-='+mov*imgWidth},1000,function(){
- curidx+=mov;
- if(curidx===imgCount){
- $ct.css({marginLeft:0-imgWidth});
- curidx=0;
- }
- })
- $('.index_tt .banner_txt').eq(curidx).show().siblings().hide();
- }
- function playpre(){
- $ct.animate({marginLeft:'+='+mov*imgWidth},1000,function(){
- curidx-=mov;
- if(curidx<0){
- $ct.css({marginLeft:0-imgWidth*imgCount});
- curidx=imgCount-1;
- }
- })
- $('.index_tt .banner_txt').eq(curidx).show().siblings().hide();
- }
-
- var timer=setInterval(playnext,3000)
- $('.banner').mouseenter(function(){
- clearInterval(timer)
- })
- $('.banner').mouseleave(function(){
- timer=setInterval(playnext,3000)
- })
- $('.img_list ol li').hover(function(){
- var simg = $(this).children('img').attr('src')
- $('.banner_box ul li').eq(curidx+1).find('img').attr('src',simg)
- })
- //导航
- $(window).scroll(function(){
- var scrolltop=$(document).scrollTop()
- if(scrolltop>400){
- $('header').addClass('h_fix')
- $('body').css({paddingTop:'74px'})
- }else{
- $('header').removeClass('h_fix')
- $('body').css({paddingTop:0})
- }
- });
-
- //挂件
- $('.pendent_box').click(function(e){
- e.preventDefault();
- $("body,html").animate({scrollTop:0},1000)
- });
- // $(window).scroll(function(){
- // var scrolltop=$(document).scrollTop()
- // if(scrolltop>700){
- // $('.pendent_box').fadeIn(200);
- // }else{
- // $('.pendent_box').fadeOut(200);
- // }
- // });
- })
|