function getbyclass(oparent, sclass) {//通过classname获取对象 var achild = oparent.getelementsbytagname('*'); var regex = new regexp('\\b' + sclass + '\\b', 'i'); var result = []; for (var i=0; i650 ? (windowheight-0) : 650; $(".box").css('height', boxheight);//初始化.box的高度 $(".b1_fixed").css('top', (boxheight-650)/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 + 0) * line.scrollratio + "px"; var page_1 = 0, page_2 = line.scrollratio*boxheight, page_3 = line.scrollratio*boxheight*2, page_4 = line.scrollratio*boxheight*3, page_5 = line.scrollratio*boxheight*4, page_6 = line.scrollratio*boxheight*5, page_7 = line.scrollratio*boxheight*6; var beforepage = line.scrollratio*200, afterpage = line.scrollratio*200; var speedtop = 800; var scale = (line.lineheight + 0 - windowheight)/((line.lineheight + 0) * line.scrollratio - windowheight); //fixed line.obj.push({ dom: ".b1_fixed", regions: [{ starttop: 0, endtop: (boxheight-570)/scale, startcss: { top: (boxheight-650)/2 }, endcss: { top: boxheight-650 } }] }, { dom: ".b2_fixed", regions: [{ starttop: 510/scale, endtop: (boxheight*2-510)/scale, startcss: { top: 0 }, endcss: { top: boxheight-570 } }] }, { dom: ".b3_fixed", regions: [{ starttop: (boxheight+510)/scale, endtop: (boxheight*3-510)/scale, startcss: { top: 0 }, endcss: { top: boxheight-570 } }] }, { dom: ".b4_fixed", regions: [{ starttop: (boxheight*2+510)/scale, endtop: (boxheight*4-510)/scale, startcss: { top: 0 }, endcss: { top: boxheight-570 } }] }, { dom: ".b5_fixed", regions: [{ starttop: (boxheight*3+510)/scale, endtop: (boxheight*5-510)/scale, startcss: { top: 0 }, endcss: { top: boxheight-570 } }] }, { dom: ".b6_fixed", regions: [{ starttop: (boxheight*4+510)/scale, endtop: (boxheight*6-510)/scale, startcss: { top: 0 }, endcss: { top: boxheight-570 } }] }, { dom: ".b7_fixed", regions: [{ starttop: (boxheight*5+510)/scale, endtop: (boxheight*7-510)/scale, startcss: { top: 0 }, endcss: { top: boxheight-570 } }] }); //box bg line.obj.push({ dom: ".box1_bg", regions: [{ starttop: 0, endtop: (boxheight-60)/scale, startcss: { top: 0 }, endcss: { top: boxheight - 1100 } }] }, { dom: ".box2_bg", regions: [{ starttop: 0, endtop: (boxheight*2-0)/scale, startcss: { top: 0 }, endcss: { top: boxheight - 1100 } }] }, { dom: ".box3_bg", regions: [{ starttop: boxheight/scale, endtop: boxheight*3/scale, startcss: { top: 0 }, endcss: { top: boxheight - 1100 } }] }, { dom: ".box4_bg", regions: [{ starttop: boxheight*2/scale, endtop: boxheight*4/scale, startcss: { top: 0 }, endcss: { top: boxheight - 1100 } }] }, { dom: ".box5_bg", regions: [{ starttop: boxheight*3/scale, endtop: boxheight*5/scale, startcss: { top: 0 }, endcss: { top: boxheight - 1100 } }] }, { dom: ".box6_bg", regions: [{ starttop: boxheight*4/scale, endtop: boxheight*6/scale, startcss: { top: 0 }, endcss: { top: boxheight - 1100 } }] }, { dom: ".box7_bg", regions: [{ starttop: boxheight*5/scale, endtop: boxheight*7/scale, startcss: { top: 0 }, endcss: { top: boxheight - 1100 } }] }); //box1 line.obj.push({ dom: ".b1_04", regions: [{ starttop: page_1, endtop: page_2, startcss: { top: 470 }, endcss: { top: 400 + 470 } }] }); //box2 --> box3 // line.obj.push({ // dom: ".b2_03", // regions: [{ // starttop: page_1, // endtop: page_3, // startcss: { // top: -400 // }, // endcss: { // top: 600 + 30 // } // }] // }, { // dom: ".b2_04", // regions: [{ // starttop: page_1, // endtop: page_3, // startcss: { // top: -100 // }, // endcss: { // top: 200+ 350 // } // }] // }, { // dom: ".b2_06", // regions: [{ // starttop: page_1, // endtop: page_3, // startcss: { // top: -200 // }, // endcss: { // top: speedtop/2 + 300 // } // }] // }); // line.obj.push({ // dom: ".b4_fixed", // regions: [{ // starttop: (page_3 + 800)/(line.lineheight + 60 - windowheight)*((line.lineheight + 60) * line.scrollratio - windowheight), // endtop: page_5-800, // startcss: { // top: -100 // }, // endcss: { // top: boxheight-750 // } // }] // }); // line.obj.push({ // dom: ".b6_fixed", // regions: [{ // starttop: (page_5 + 800)/(line.lineheight + 60 - windowheight)*((line.lineheight + 60) * line.scrollratio - windowheight), // endtop: page_7-800, // startcss: { // top: -50 // }, // endcss: { // top: boxheight-750 // } // }] // }); // line.obj.push({ // dom: ".b7_fixed", // regions: [{ // starttop: (page_6 + 800)/(line.lineheight + 60 - windowheight)*((line.lineheight + 60) * line.scrollratio - windowheight), // endtop: page_7, // startcss: { // top: 0 // }, // endcss: { // top: boxheight-800 // } // }] // }); 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 = 0 - 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 + 0 - windowheight)*((line.lineheight + 0) * 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+60}); var wraptop = top*(line.lineheight + 0 - windowheight)/((line.lineheight + 0) * line.scrollratio - windowheight);//内容改变top值 //$wrapbox.css({"top": -wraptop+60}); $wrapbox.stop().animate({"top": -wraptop+0}, 1300);//#wrap 滚动 //$wrapbox.stop().animate({"top": -wraptop+60},{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++; if (boxheight*(topindex-0.4) < wraptop) { $(".nav a").removeclass("cur").eq(7).addclass("cur"); $(".fixednav li").removeclass("cur").eq(7).addclass("cur"); } 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();//默认第一个 $(".nav li").click(function() { var index = $(this).index(); index = index==0 ? 0 : index; window.scroll(0, index * line.scrollratio * boxheight); //document.getelementsbytagname('body')[0].scrolltop = index * line.scrollratio * boxheight; }); $(".fixednav").css({'margin-left': $(window).width()/2-40, 'display': 'block'}); $(".fixednav li").click(function() { var index = $(this).index(); index = index==0 ? 0 : index; //document.getelementsbytagname('body')[0].scrolltop = index * line.scrollratio * boxheight; 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": { opacity: 0, left:200, top:120, }, ".b1_02": { left: 300, top:250, opacity: 0 }, ".b1_03": { top: 360, left:300, opacity: 0 }, ".b2_01": { left: 100, top: 180, opacity: 0 }, ".b2_02": { left: 295, top: 310, opacity: 0 }, ".b2_03": { left: 200, top: 390, opacity: 0 }, ".b3_01": { left: 100, top: 180, opacity: 0 }, ".b3_02": { left: 380, top: 310, opacity: 0 }, ".b3_03": { left: 100, top: 390, opacity: 0 }, ".b4_01": { left: 600, top:140, opacity: 0 }, ".b4_02": { left: 295, top:310, opacity: 0 }, ".b4_03": { left: 163, top:390, opacity: 0 }, ".b4_04": { left: 1400, top:390, opacity: 0 }, ".b5_01": { left: 100, top:180, opacity: 0 }, ".b5_02": { left: 300, top: 310, opacity: 0 }, ".b5_03": { left: 100, top: 390, opacity: 0 }, ".b5_04": { left: 100, top:392, opacity: 0 }, ".b5_05": { left: 1405, top: 390, opacity: 0 }, ".b5_06": { left: 1400, top: 460, opacity: 0 }, } var box1in = true, box2in = true, box3in = true, box4in = true, box5in = true, box6in = true; function boxgoin_1() { box1in = false; $(".b1_01").stop().animate({top: 120, left: 746, opacity: 1}, 800); $(".b1_02").stop().animate({top: 250, left: 480, opacity: 1}, 1200); $(".b1_03").stop().animate({top: 360, left:870, opacity: 1}, 1200); } function boxgoout_1() { box1in = true; $(".b1_01").stop().animate({top: 120, left: 200, opacity: 0}, 800); $(".b1_02").stop().animate({top: 250, left: 300, opacity: 0}, 500); $(".b1_03").stop().animate({top: 360, left:300, opacity: 0}, 500); } function boxgoin_2() { box2in = false; $(".b2_01").stop().animate({left: 360, top: 180, opacity: 1}, 800); $(".b2_02").stop().animate({left: 594, top:310, opacity: 1}, 1000); $(".b2_03").stop().animate({left: 365, top:390, opacity: 1}, 1000); } function boxgoout_2() { box2in = true; $(".b2_01").stop().animate({left: 100, top: 180, opacity: 0}, 800); $(".b2_02").stop().animate({left: 295, top:310, opacity: 0}, 300); $(".b2_03").stop().animate({left: 200, top:390, opacity: 0}, 800); } function boxgoin_3() { box3in = false; $(".b3_01").stop().animate({left: 360, top: 180, opacity: 1}, 800); $(".b3_02").stop().animate({left: 715, top: 310, opacity: 1}, 1000); $(".b3_03").stop().animate({left: 360, top:390, opacity: 1}, 1000); } function boxgoout_3() { box3in = true; $(".b3_01").stop().animate({left: 100, top: 180, opacity: 0}, 500); $(".b3_02").stop().animate({left: 380, top: 310, opacity: 0}, 800); $(".b3_03").stop().animate({left: 100, top:390, opacity: 0}, 800); } function boxgoin_4() { box4in = false; $(".b4_01").stop().animate({left: 360, top: 180, opacity: 1}, 800); $(".b4_02").stop().animate({left: 594, top:310, opacity: 1}, 1000); $(".b4_03").stop().animate({left: 363, top:390, opacity: 1}, 1000); $(".b4_04").stop().animate({left: 1190, top: 390, opacity: 1}, 800); } function boxgoout_4() { box4in = true; $(".b4_01").stop().animate({left: 160, top: 180, opacity: 0}, 800); $(".b4_02").stop().animate({left: 295, top: 310, opacity: 0}, 800); $(".b4_03").stop().animate({left: 163, top:390, opacity: 0}, 1000); $(".b4_04").stop().animate({left: 1400, top: 390, opacity: 0}, 800); } function boxgoin_5() { box5in = false; $(".b5_01").stop().animate({left: 360, top: 180, opacity: 1}, 800); $(".b5_02").stop().animate({left: 668, top: 310, opacity: 1}, 1000); $(".b5_03").stop().animate({left: 365, top: 390, opacity: 1}, 1000); $(".b5_04").stop().animate({left: 368, top: 392, opacity: 1}, 800); $(".b5_05").stop().animate({left: 860, top: 390, opacity: 1}, 1000); $(".b5_06").stop().animate({left: 903, top: 460, opacity: 1}, 1000); } function boxgoout_5() { box5in = true; $(".b5_01").stop().animate({left: 100, top: 180, opacity: 0}, 800); $(".b5_02").stop().animate({left: 300, top: 310, opacity: 0}, 800); $(".b5_03").stop().animate({left: 100, top: 390, opacity: 0}, 800); $(".b5_04").stop().animate({left: 100, top: 392, opacity: 0}, 800); $(".b5_05").stop().animate({left: 1405, top: 390, opacity: 0}, 800); $(".b5_06").stop().animate({left: 1400, top: 460, opacity: 0}, 800); } // function loadimg() { // var oload = document.getelementbyid('load'), // oloadimg = document.getelementbyid('loadimg'), // oloadtxt = document.getelementbyid('loadtxt'), // image_path = '/bocmobile/img/', // aimgs = ['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', // 'b3_01.png', // 'b3_bg.jpg', // 'b4_01.png', // 'b4_02.png', // 'b4_bg.jpg', // 'b5_01.png', // 'b5_bg.jpg', // 'b5_ico.png', // 'b66.png', // 'b6_01.png', // 'b6_arrow.png', // 'b6_bg.jpg', // 'b6_ico.png', // 'b6_img.png', // 'b7_bg.jpg', // 'b7_sprite.png', // 'box_bg01.jpg', // 'logo.jpg', // 'map.jpg', // 'sprite.png'], // len = aimgs.length, i=0, j=0; // document.body.style.overflow = 'hidden'; // for (; i