$(function () { //头部轮播 (function () { var $shuffingUl = $("#banner .shuffling .picture"), $shufflingLi = $shuffingUl.children("li"), $Logo = $("#banner .shuffling .logo"), $Left = $("#banner .shuffling .left"), $Title = $("#banner .shuffling .title"), $Title1 = $("#banner .shuffling .title1"), $Title2 = $("#banner .shuffling .title2"), $Pager = $("#banner .shuffling .pager li"), index = 0, len = $shufflingLi.length; $shufflingLi.css("width",$(window).width() + "px"); $shuffingUl.css({ "width":$shufflingLi.width()*len+"px", "marginLeft":-$shufflingLi.width()*(index+1)+"px" }); var timer; $Pager.hover(function () { clearInterval(timer); },function () { timer = setInterval(function(){ index++; change() },4000); }); $Pager.click(function(){ index = $(this).index(); $(this).addClass('on').siblings().removeClass('on'); $shuffingUl.animate({ marginLeft : -$shufflingLi.width()*(index+1) + 'px' },300); if (index === 0){ $Title.stop().animate({ "opacity":"1" },800); }else { $Title.stop().animate({ "opacity":"0" },800); } if (index === 1){ $Title1.stop().animate({ "opacity":"1", "right":"20%" },800); }else { $Title1.stop().animate({ "opacity":"0", "right":"80%" },800); } if (index === 2){ $Title2.stop().animate({ "opacity":"1", "left":"26%" },800); }else { $Title2.stop().animate({ "opacity":"0", "left":"60%" },800); } }); timer = setInterval(function(){ index++; console.log(index+"index0") change() },4000); setTimeout(function () { $Left.stop().animate({ "left":"0" },1000); $Logo.stop().animate({ "left":"7%", "opacity":"1" },700); $Title.stop().animate({ "left":"26%", "opacity":"1" },800); },1000); function change() { var liIndex = index-1; if ( liIndex >= $Pager.length ) { liIndex = 0; } else if ( liIndex < 0 ) { liIndex = $Pager.length-1; } $Pager.eq(liIndex).addClass('on').siblings().removeClass('on'); $shuffingUl.animate({ marginLeft : -$shufflingLi.width()*index + 'px' },800,function(){ if ( index === len-1 ) { $shuffingUl.css('marginLeft' , -$shufflingLi.width()+'px'); index = 0; } else if ( index < 0 ) { $shuffingUl.css('marginLeft' , -$shufflingLi.width()*len+'px'); index = len-1; } }); if (index === 0 || index === 1){ $Title.stop().animate({ "opacity":"1" },800); }else { $Title.stop().animate({ "opacity":"0" },800); } if (index === 2){ $Title1.stop().animate({ "opacity":"1", "right":"20%" },800); }else { $Title1.stop().animate({ "opacity":"0", "right":"80%" },800); } if (index === 3){ $Title2.stop().animate({ "opacity":"1", "left":"26%" },800); }else { $Title2.stop().animate({ "opacity":"0", "left":"60%" },800); } } })(); // (function (){ var $H2 = $("#content .scenery .right h2"); $(window).scroll(titleFun()); function titleFun(){ if($(document).scrollTop()>$H2.offset().top-600){ $H2.animate({opacity:"1", marginLeft:"0"},1000); } return titleFun; } })(); //数字滚动 (function () { // var $Num = $("#content .number ul li div span"); /*setTimeout(function () { var arr = [], str; for (var i=0;i<$Num.html().length;i++){ str = $Num.html().slice(i,i+1); arr.push(str); for (var j = 0; j<= 10 ;j++){ arr[i] +=j; } } console.log(arr); },1000) console.log($Num.html().length); console.log($Num.html());*/ /* @param {Object} Dom元素 @param {Object} 初始值 @param {Object} 最大值 @param {Object} 时间 */ // function numRunFun(Box,num,maxNum,i,t) { // var numText = num, // timer; // function numSlideFun() { // numText += i; // if (numText >= maxNum){ // numText=maxNum; // clearTimeout(timer); // } else { // timer = setTimeout(numSlideFun,t); // } // // Box.html(numText); // } // numSlideFun(); // // //numText=parseFloat(numText).toLocaleString(); // // } $(window).scroll(scrollTop()); var i=0; function scrollTop() { // if($(document).scrollTop() > $Num.offset().top -600){ // // if(i!=1){ // // numRunFun($Num.eq(0),0,300,10,100); // // numRunFun($Num.eq(1),0,30,1,100); // // numRunFun($Num.eq(2),0,19,1,200); // // numRunFun($Num.eq(3),0,200,10,150); // // i=1; // } // } // return scrollTop; } })(); //科研中心 (function () { var $CenterLi = $("#content .scientific .center > ul > li"), $Title = $("#content .scientific .center .round h4"), $RoundLi = $("#content .scientific .center .round ul li"); $CenterLi.hover( function () { $Title.stop().fadeOut(500); $RoundLi.eq($(this).index()).stop().fadeIn(500).siblings().stop().fadeOut(500); }, function () { $RoundLi.stop().fadeOut(500); $Title.stop().fadeIn(500); }); })(); });