//锚点 var anchorc=function(mouseyn,cuthead,num){ var scltop=0; var clicky=false; var nowtab=0; var hh=0; if(cuthead){ hh=num; } for(var i=0; i<$('.w-section').length; i++){ if($(window).scrolltop()>$('.w-section').eq(i).offset().top-hh) { if($('.banner').is(':visible') || $('.videobn').is(':visible')){ nowtab=i+1; }else{ nowtab=i; } } } var curadd=function(){ $('.anchor li').removeclass('cur bg_main'); $('.anchor li').eq(nowtab).addclass('cur bg_main'); } var mousew=function(){ if($(window).width()>1200){ $("body").mousewheel(function(event, delta, deltax, deltay ) { clicky=true; if(delta<0){ var scro1=function (){ if($('.banner').is(':visible') || $('.videobn').is(':visible')){ if(nowtab < $('.w-section').length){ if($(window).scrolltop()+$(window).height()>$('.w-section').eq(nowtab).offset().top-hh){ nowtab=nowtab+1; scltop=$('.w-section').eq(nowtab-1).offset().top-hh; $('body,html').stop().animate({scrolltop: scltop}, 300); curadd(); settimeout(function () {clicky=false;}, 400); } } }else{ if(nowtab < $('.w-section').length-1){ if($(window).scrolltop()+$(window).height()>$('.w-section').eq(nowtab+1).offset().top-hh){ nowtab=nowtab+1; scltop=$('.w-section').eq(nowtab).offset().top-hh; $('body,html').stop().animate({scrolltop: scltop}, 300); curadd(); settimeout(function () {clicky=false;}, 400); } } } } settimeout(scro1, 150); }else if(delta>0){ var scro2=function (){ if($('.banner').is(':visible') || $('.videobn').is(':visible')){ if(nowtab){ if($(window).scrolltop()<$('.w-section').eq(nowtab-1).offset().top-hh){ nowtab=nowtab-1; if(nowtab==0){ $('body,html').stop().animate({scrolltop: 0}, 'normal'); }else{ scltop=$('.w-section').eq(nowtab-1).offset().top-hh; $('body,html').stop().animate({scrolltop: scltop}, 300); } curadd(); settimeout(function () {clicky=false;}, 400); } } }else{ if(nowtab>0){ if($(window).scrolltop()<$('.w-section').eq(nowtab).offset().top-hh){ nowtab=nowtab-1; if(nowtab==0){ $('body,html').stop().animate({scrolltop: 0}, 'normal'); }else{ scltop=$('.w-section').eq(nowtab).offset().top-hh; $('body,html').stop().animate({scrolltop: scltop}, 300); } curadd(); settimeout(function () {clicky=false;}, 400); } } } } settimeout(scro2, 150); } }); } } curadd(); if(mouseyn){ mousew(); } $(window).scroll(function(){ if(!clicky){ if($('.banner').is(':visible') || $('.videobn').is(':visible')){ if(nowtab < $('.w-section').length){ if($(window).scrolltop()>$('.w-section').eq(nowtab).offset().top-hh){ nowtab=nowtab+1; curadd(); } } if(nowtab){ if($(window).scrolltop()<$('.w-section').eq(nowtab-1).offset().top-hh){ nowtab=nowtab-1; curadd(); } } }else{ if(nowtab < $('.w-section').length-1){ if($(window).scrolltop()>$('.w-section').eq(nowtab+1).offset().top-hh){ nowtab=nowtab+1; curadd(); } } if(nowtab>0){ if($(window).scrolltop()<$('.w-section').eq(nowtab).offset().top){ nowtab=nowtab-1; curadd(); } } } } }); $('.anchor li').each(function(index, element) { $(this).click(function(){ nowtab=index; $(this).siblings('li').removeclass('cur bg_main'); $(this).addclass('cur bg_main'); if(nowtab==0){ clicky=true; $('body,html').stop().animate({scrolltop: 0}, 'normal'); settimeout(function () {clicky=false;}, 600); }else{ if($('.banner').is(':visible') || $('.videobn').is(':visible')){ clicky=true; scltop=$('.w-section').eq(nowtab-1).offset().top-hh; $('body,html').stop().animate({scrolltop: scltop}, 500); settimeout(function () {clicky=false;}, 600); }else{ clicky=true; scltop=$('.w-section').eq(nowtab).offset().top-hh; $('body,html').stop().animate({scrolltop: scltop}, 500); settimeout(function () {clicky=false;}, 600); } } }); }); }