|
@@ -1,40 +1,66 @@
|
|
|
|
|
|
$(function(){
|
|
|
- $('.index_tt .banner_txt').eq(0).show().siblings().hide();
|
|
|
- var i=0;
|
|
|
- var wimg=$('.banner_box ul li').width();
|
|
|
- var lilength=$('.banner_box ul li').length;
|
|
|
- function next(){
|
|
|
- i++;
|
|
|
- if(i>lilength-1){
|
|
|
- i=0;
|
|
|
- };
|
|
|
- $('.banner_box ul').animate({'marginLeft':-wimg*(i)+'px'})
|
|
|
- $('.index_tt .banner_txt').eq(i).show().siblings().hide();
|
|
|
- }
|
|
|
- function pre(){
|
|
|
- i--;
|
|
|
- if(i<0){
|
|
|
- i = lilength-1
|
|
|
- }
|
|
|
- $('.banner_box ul').animate({'marginLeft':-wimg*i+'px'})
|
|
|
- $('.index_tt .banner_txt').eq(i).show().siblings().hide();
|
|
|
- }
|
|
|
- var timer=setInterval(next,2000)
|
|
|
+ $('.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;
|
|
|
+ var lock=false;
|
|
|
+ function playnext(){
|
|
|
+ $ct.animate({marginLeft:'-='+mov*imgWidth},function(){
|
|
|
+ curidx++;
|
|
|
+ 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},function(){
|
|
|
+ curidx--;
|
|
|
+ if(curidx===(-1)){
|
|
|
+ $ct.css({marginLeft:0-imgWidth*imgCount});
|
|
|
+ curidx=3;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $('.index_tt .banner_txt').eq(curidx).show().siblings().hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ var timer=setInterval(playnext,3000)
|
|
|
$('.banner').mouseenter(function(){
|
|
|
clearInterval(timer)
|
|
|
})
|
|
|
$('.banner').mouseleave(function(){
|
|
|
- timer=setInterval(next,2000)
|
|
|
- })
|
|
|
- $('.banner_next').click(function(){
|
|
|
- next();
|
|
|
- })
|
|
|
- $('.index_pre').click(function(){
|
|
|
- pre();
|
|
|
- })
|
|
|
- $('.img_list ol li').hover(function(){
|
|
|
+ timer=setInterval(playnext,3000)
|
|
|
+ })
|
|
|
+ $('.img_list ol li').hover(function(){
|
|
|
var simg = $(this).children('img').attr('src')
|
|
|
- $('.banner_box ul li').eq(i).find('img').attr('src',simg)
|
|
|
- })
|
|
|
+ $('.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})
|
|
|
+ }
|
|
|
+ });
|
|
|
})
|