function getByClass(oParent, sClass) {//通过className获取对象 var aChild = oParent.getElementsByTagName('*'); var regex = new RegExp('\\b' + sClass + '\\b', 'i'); var result = []; for (var i=0; i570 ? (windowHeight-68) : 570; $(".box").css('height', boxHeight);//初始化.box的高度 $(".b1_").css('top', (boxHeight-570)/2);//初始化.box的高度 var line = { lineHeight: boxHeight*$(".box").length,//虚拟轴高度 pageIndex: 0,//当前page索引 scrollRatio: 1,//滚动条和虚拟轴的比率,越大则滚动得越慢(滚动条滚几倍,虚拟轴才滚1) isAnimRuning: false,//自动滚动 obj:[]//虚拟轴上的运动对象 };//虚拟轴 document.getElementsByTagName("body")[0].style.height = (line.lineHeight + 68) * line.scrollRatio + "px"; var page_1 = 0, page_2 = line.scrollRatio*boxHeight, page_3 = line.scrollRatio*boxHeight*4, page_4 = line.scrollRatio*boxHeight*3, page_5 = line.scrollRatio*boxHeight*4, page_6 = line.scrollRatio*boxHeight*5, page_7 = line.scrollRatio*boxHeight*6; page_8 = line.scrollRatio*boxHeight*7; page_9 = line.scrollRatio*boxHeight*8; page_10 = line.scrollRatio*boxHeight*9; page_11 = line.scrollRatio*boxHeight*10; page_12 = line.scrollRatio*boxHeight*11; var beforePage = line.scrollRatio*200, afterPage = line.scrollRatio*200; var speedTop = 800; var scale = (line.lineHeight + 68 - windowHeight)/((line.lineHeight + 68) * line.scrollRatio - windowHeight); var oBody = document.getElementsByTagName('body')[0]; var scrollNum = 1; if(oBody.addEventListener) { oBody.addEventListener('DOMMouseScroll', function(e){ scrollFunc(e); }, false); } oBody.onmousewheel = function(e){ scrollFunc(e); }; function scrollFunc(e) { var e = e || event; var wrapTop = 68 - document.getElementById("wrapBox").offsetTop; var direct; var endWrapTop; e.preventDefault ? e.preventDefault() : (e.returnValue = false); direct = e.wheelDelta ? e.wheelDelta : e.detail*-1; if (direct > 0) { if ((scrollNum++)%2) { return; } endWrapTop = (Math.round(wrapTop/boxHeight*1)-1) * boxHeight/1; } else { if ((scrollNum--)%2) { return; } endWrapTop = (Math.round(wrapTop/boxHeight*1)+1) * boxHeight/1; } window.scroll(0, endWrapTop/(line.lineHeight + 68 - windowHeight)*((line.lineHeight + 68) * line.scrollRatio - windowHeight)); } var endTop = 0; window.onscroll = function() { var top = document.documentElement.scrollTop || document.body.scrollTop;//获取滚动条位置 // if (endTop > top) { // clearInterval(bodyTimer); // } endTop = top; //$wrapBox.css({"top": -top2+68}); var wrapTop = top*(line.lineHeight + 68 - windowHeight)/((line.lineHeight + 68) * line.scrollRatio - windowHeight);//内容改变top值 //$wrapBox.css({"top": -wrapTop+68}); $wrapBox.stop().animate({"top": -wrapTop+68}, 1300);//#wrap 滚动 //$wrapBox.stop().animate({"top": -wrapTop+68},{queue:false, duration: 1100}); var topIndex = 0; if (wrapTop <= boxHeight*(topIndex + 0.6)) { if (box1In) { boxGoIn_1(); } $(".nav a").removeClass("cur").eq(0).addClass("cur"); $(".fixedNav li").removeClass("cur").eq(0).addClass("cur"); } else if (wrapTop > boxHeight*(topIndex + 0.8)) { boxGoOut_1(); } topIndex++; if (boxHeight*(topIndex-0.4) < wrapTop && wrapTop < boxHeight*(topIndex+0.6)) { if (box2In) { boxGoIn_2(); } $(".nav a").removeClass("cur").eq(1).addClass("cur"); $(".fixedNav li").removeClass("cur").eq(1).addClass("cur"); } else if (wrapTop > boxHeight*(topIndex+0.8) || wrapTop < boxHeight*(topIndex-0.4)) { boxGoOut_2(); } topIndex++; if (boxHeight*(topIndex-0.4) < wrapTop && wrapTop < boxHeight*(topIndex+0.6)) { if (box3In) { boxGoIn_3(); } $(".nav a").removeClass("cur").eq(2).addClass("cur"); $(".fixedNav li").removeClass("cur").eq(2).addClass("cur"); } else if (wrapTop > boxHeight*(topIndex+0.8) || wrapTop < boxHeight*(topIndex-0.4)) { boxGoOut_3(); } topIndex++; if (boxHeight*(topIndex-0.4) < wrapTop && wrapTop < boxHeight*(topIndex+0.6)) { if (box4In) { boxGoIn_4(); } $(".nav a").removeClass("cur").eq(3).addClass("cur"); $(".fixedNav li").removeClass("cur").eq(3).addClass("cur"); } else if (wrapTop > boxHeight*(topIndex+0.8) || wrapTop < boxHeight*(topIndex-0.4)) { boxGoOut_4(); } topIndex++; if (boxHeight*(topIndex-0.4) < wrapTop && wrapTop < boxHeight*(topIndex+0.6)) { if (box5In) { boxGoIn_5(); } $(".nav a").removeClass("cur").eq(4).addClass("cur"); $(".fixedNav li").removeClass("cur").eq(4).addClass("cur"); } else if (wrapTop > boxHeight*(topIndex+0.8) || wrapTop < boxHeight*(topIndex-0.4)) { boxGoOut_5(); } topIndex++; if (boxHeight*(topIndex-0.4) < wrapTop && wrapTop < boxHeight*(topIndex+0.6)) { if (box6In) { boxGoIn_6(); } $(".nav a").removeClass("cur").eq(5).addClass("cur"); $(".fixedNav li").removeClass("cur").eq(5).addClass("cur"); } else if (wrapTop > boxHeight*(topIndex+0.8) || wrapTop < boxHeight*(topIndex-0.4)) { boxGoOut_6(); } topIndex++; if (boxHeight*(topIndex-0.4) < wrapTop && wrapTop < boxHeight*(topIndex+0.6)) { if (box7In) { boxGoIn_7(); } $(".nav a").removeClass("cur").eq(6).addClass("cur"); $(".fixedNav li").removeClass("cur").eq(6).addClass("cur"); } else if (wrapTop > boxHeight*(topIndex+0.8) || wrapTop < boxHeight*(topIndex-0.4)) { boxGoOut_7(); } topIndex++; for (var i=0, len=line.obj.length; i= top) { parallaxAnimate(curEle.dom, curEle.regions[j], top); } else if (curEle.regions[j].endTop <= top) { for (var n in curEle.regions[j].endCss) { var json = {}; json[n] = curEle.regions[j].endCss[n]; //$(curEle.dom).css(json); $(curEle.dom).stop().animate(json, 1300); } } else if (curEle.regions[j].startTop >= top) { for (var n in curEle.regions[j].startCss) { var json = {}; json[n] = curEle.regions[j].startCss[n]; //$(curEle.dom).css(json); $(curEle.dom).stop().animate(json, 1300); } } } } }; for (var i in elementInit) {//初始化对象 var $i = $wrapBox.find(i); for (var j in elementInit[i]) { $i.css(j, elementInit[i][j]); } } boxGoIn_1();//默认第一个 var indexes = [0,1,2,3,4,5,6]; $(".nav li").click(function() { var index = indexes[$(this).index()]; window.scroll(0, index * line.scrollRatio * boxHeight); }); $(".fixedNav").css({'margin-left': $(window).width()/2-40, 'display': 'block'}); $(".fixedNav li").click(function() { var index = indexes[$(this).index()]; window.scroll(0, index * line.scrollRatio * boxHeight); }); $(".fixedNav li").hover(function(){ $(this).find('.txt').show(); }, function() { $(this).find('.txt').hide(); }) var lazyload; window.onresize = function() { clearTimeout(lazyload); lazyload = setTimeout(function() { window.location.reload(); document.documentElement.scrollTop = document.body.scrollTop = 0; }, 500); //$(".fixedNav").css('margin-left', $(window).width()/2-50); }; //var bodyTimer; //$(".b1_03 a").click(function() { //clearInterval(bodyTimer); //var now = 1; //$(".nav a").eq(1).click(); //document.getElementsByTagName('body')[0].scrollTop = document.documentElement.scrollTop = now * line.scrollRatio * boxHeight; // document.body.scrollTop = now * line.scrollRatio * boxHeight; // bodyTimer = setInterval(function() { // now++; // document.documentElement.scrollTop = document.body.scrollTop = now * line.scrollRatio * boxHeight; // if (now >= 7) { // clearInterval(bodyTimer); // } // }, 5000); //}); }; var elementInit = {//初始化对象属性 ".b1_01": { marginTop: 1000, opacity: 0 }, ".b2_01": { marginTop:1000, opacity: 0 }, ".b3_01": { marginTop: 1000, opacity: 0 }, ".b4_01": { marginTop: 1000, opacity: 0 }, ".b5_01": { marginTop: 1000, opacity: 0 }, ".b6_01": { marginTop: 1000, opacity: 0 }, ".b7_01": { marginTop: 1000, opacity: 0 }, ".b5_02": { marginTop: 1000, opacity: 0 }, ".b5_03": { marginTop: 1000, opacity: 0 }, ".b5_04": { marginTop: 1000, opacity: 0 }, ".b5_05": { marginTop: 1000, opacity: 0 }, ".b5_06": { marginTop: 1000, opacity: 0 }, ".b6_07": { marginTop: 1000, opacity: 0 } } var box1In = true, box2In = true, box3In = true, box4In = true, box5In = true, box6In = true, box7In = true function boxGoIn_1() { box1In = false; $(".b1_01").stop().animate({marginTop: -146, opacity: 1}, 1200); } function boxGoOut_1() { box1In = true; $(".b1_01").stop().animate({marginTop: 1000, opacity: 0}, 800); } function boxGoIn_2() { box2In = false; $(".b2_01").stop().animate({marginTop:-121, opacity: 1}, 800); } function boxGoOut_2() { box2In = true; $(".b2_01").stop().animate({marginTop: 1000, opacity: 0}, 400); } function boxGoIn_3() { box3In = false; $(".b3_01").stop().animate({marginTop:-209, opacity: 1}, 800); } function boxGoOut_3() { box3In = true; $(".b3_01").stop().animate({marginTop: 1000, opacity: 0}, 400); } function boxGoIn_4() { box4In = false; $(".b4_01").stop().animate({marginTop: -330, opacity: 1}, 800); } function boxGoOut_4() { box4In = true; $(".b4_01").stop().animate({marginTop: 1000, opacity: 0}, 400); } function boxGoIn_5() { box5In = false; $(".b5_01").stop().animate({marginTop: -311, opacity: 1}, 800); } function boxGoOut_5() { box5In = true; $(".b5_01").stop().animate({marginTop: 1000, opacity: 0}, 400); } function boxGoIn_6() { box6In = false; $(".b6_01").stop().animate({marginTop:-241, opacity: 1}, 800); } function boxGoOut_6() { box6In = true; $(".b6_01").stop().animate({marginTop:1000, opacity: 0}, 400); } function boxGoIn_7() { box7In = false; $(".b7_01").stop().animate({marginTop:-241, opacity: 1}, 800); } function boxGoOut_7() { box7In = true; $(".b7_01").stop().animate({marginTop:1000, opacity: 0}, 400); } var loadImg = { path: './img/', imgs: { '.b1_bg': ['b1_01.png', 'b1_02.png', 'b1_03.png', 'b1_03_btn.png', 'b1_04.png', 'b1_bg.jpg', 'b2_01.png', 'b2_03.png', 'b2_04.png', 'b2_05.png', 'b2_06.png', 'b2_bg.jpg', 'sprite.png'], '.b3_bg': ['b3_01.png', 'b3_bg.jpg'], '.b4_bg': ['b4_01.png', 'b4_02.png', 'b4_bg.jpg'], '.b5_bg': ['b5_01.png', 'b5_bg.jpg', 'b5_ico.png'], '.b6_bg': ['b6_01.png', 'b6_arrow.png', 'b6_bg.jpg', 'b6_ico.png', 'b6_img.png'], '.b7_bg': ['b7_bg.jpg', 'b7_sprite.png', 'map.jpg'] }, boxLoad: function(ele, aImgs, callback) { var len = aImgs.length, i=0, j=0, imgLoad = [], _self = this; for (; i