var isIE6 = !-[1,] && !window.XMLHttpRequest, isIE = !!window.ActiveXObject, isIE7 = isIE && navigator.appVersion.split(";")[1].replace(/[ ]/g,"")=="MSIE7.0"; // 绂佹娴忚鍣ㄩ粯璁よ涓 function stopDefault(e) { var e= e || event; if (e.preventDefault) { e.preventDefault(); } else { window.event.returnValue = false; } return false; } // //鍥剧墖鍗犳弧 //// // function imgFull(imgParent) { /***** 鍥剧墖灏哄鑷€傚簲鐖剁骇瀹瑰櫒锛屼笉鍙樺舰 * 涓嶅浐瀹氬昂瀵稿浘鐗囷紝纭繚鍦ㄧ埗绾ф拺婊 * 濡傦細鍥剧墖楂樺害姣斾緥灏忥紝鍒欓珮搴︽拺婊★紝瀹藉害瓒呭嚭鎴彇 * imgParent: 闇€瑕佽嚜閫傚簲鐨勫浘鐗囩殑鐖跺鍣紝涔熷彲涓轰竴缁勫浘鐗囩殑绁栧厛瀹瑰櫒 * 鍥剧墖鍙拺婊$埗绾э紝闈炵鍏堢骇鍒 */ // 鑾峰彇鍥剧墖锛屽鏈紶鍏ュ弬鏁帮紝鍒欒幏鍙杁ata-img=full鐨勫浘鐗 var $imgArr = imgParent ? $(imgParent).find("img") : $("[data-img=full]"), len = $imgArr.length, i = 0; // 鍥剧墖鍘嬬缉(鎷変几)瑁佸壀 function init() { var width = $(this).width(), height = $(this).height(), $parent = $(this).parent(), parentWidth = $parent.width(), parentHeight = $parent.height(); // 鍒ゆ柇闀垮姣斾緥 if (width/parentWidth < height/parentHeight) { $(this).width(parentWidth); $(this).height("auto"); //alert(this.src); $(this).css({"position": "absolute", "left": "0", "top": -($(this).height() - parentHeight)/2}); } else { $(this).width("auto"); $(this).height(parentHeight); $(this).css({"position": "absolute", "top": "0", "left": -($(this).width()- parentWidth)/2}); } // 鍒ゆ柇鏄惁鍔犺浇瀹岋紝闅愯棌loading鍥炬爣 if (++i == len) { removeLoading(); } $(this).stop().animate({opacity: 1}, 0); $(".index-index").stop().animate({opacity: 1}, 0); } $imgArr.each(function() { var $parent = $(this).parent(), img = new Image(), $self = $(this); // 鍒濆鍖栫埗绾ц秴鍑洪殣钘 $parent.css({"overflow": "hidden"}); if ($parent.css("position") != "absolute") { $parent.css({"position": "relative"}); } init.call($self[0]); // 鍥剧墖鍔犺浇瀹屾垚鎵ц鍘嬬缉 img.onload = img.onComplete = function() { init.call($self[0]); this.onload = this.onerror = null; img = null; }; img.onerror = function() { img.onload = img.onerror = null; img = null; } img.src = $(this).attr("src"); }); } // loading绉婚櫎 function removeLoading() { $("body").css("overflow", "visible"); $("#loading").hide(); }; $(function() { if ($("#loading")[0]) { $("body").css("overflow", "hidden"); } }); /****************************************** *** *** *** 瀵艰埅鍖哄煙鑷姩鏀剁缉 *** *** *** ******************************************/ /***** header ******************/ var packupHeader, expansionHeader; $(function() { (function() { var $header = $(".header .top"), isExpansion = true; packupHeader = function() { if (isIE6) {return;} $header.css({"overflow":"hidden","height":"0"}); // $header.stop().animate({height: 0}, 1000, "easeInCubic"); isExpansion = false; }; expansionHeader = function() { if (isIE6) {return;} // $header.stop().animate({height: 48}, 1000, "easeInCubic"); $header.css({"overflow":"visible","height":"48px"}); // $header.css("overflow", "visible"); isExpansion = true; }; $(window).on("scroll", function() { var scrollTop = $(this).scrollTop(); if (scrollTop >= 400 && isExpansion) { packupHeader(); } else if (scrollTop < 400 && isExpansion == false) { expansionHeader(); } }); })(); }); /***鍏ㄥ睆婊氬姩****/ $(function() { //packupHeader(); var $indexWrap = $("#indexWrap"), $viewportCont = $(".viewport-cont"), $fixedViewIco = $(".fixed-view-ico a"), viewportHeight = $(window).height(), VIEWPORT_LEN = 4, // viewport 鐨勪釜鏁 curIndex = 0, canMousewheel = true, lazyScroll; touch.on('#indexWrap .viewport', 'swipedown', function(ev){ viewportGo(curIndex - 1); }); touch.on('#indexWrap .viewport', 'swipeup', function(ev){ viewportGo(curIndex + 1); }); // 婊氬姩鍒 viewport, target 涓烘粴鍔ㄥ埌鐨剉iewport鐨勭储寮 function viewportGo(target) { var direction; // 婊氬姩鏂瑰悜锛宒own 鍚戜笅婊? up鍚戜笂婊 // 鍒ゆ柇target鏄惁瓒呭嚭 target = Math.max(0, Math.min(VIEWPORT_LEN, target)); // 鍒ゆ柇鐩爣viewport鍜屽綋鍓嶇殑鏄惁鏄悓涓€涓 if (target == curIndex) { return; } // canMousewheel = false; if (target == VIEWPORT_LEN) { $indexWrap.stop().animate({"scrollTop": "+=505"}, 1000, 'easeInOutExpo', function() { canMousewheel = true; }); curIndex = VIEWPORT_LEN; return; } if (curIndex == VIEWPORT_LEN && target == VIEWPORT_LEN - 1) { $indexWrap.stop().animate({"scrollTop": "-=505"}, 1000, 'easeInOutExpo', function() { canMousewheel = true; }); curIndex = VIEWPORT_LEN - 1; return; } // 鍒ゆ柇indexWrap婊氬姩鐨勬柟鍚 direction = target > curIndex ? "down" : "up"; // 鎵ц鍏ュ満鍑哄満鍔ㄧ敾 if (curIndex != VIEWPORT_LEN) { viewportOut(curIndex, direction); } viewportIn(target, direction); if (target > 0) { packupHeader(); } else { expansionHeader(); page1Show(); } //绗竴灞忓姩鐢 if (target == 0) { $('.header').addClass('activ'); // page1Show(); } //绗簩灞忓姩鐢 if (target == 1) { $('.header').removeClass('activ'); page2Show(); } //绗笁灞忓姩鐢 if (target == 2) { $('.header').removeClass('activ'); page3Show(); } //绗洓灞忓姩鐢 if (target == 3) { $('.header').removeClass('activ'); page4Show(); } //绗簲灞忓姩鐢 if (target == 4) { page5Show(); } //绗叚灞忓姩鐢 if (target == 5) { page6Show(); } //绗竷灞忓姩鐢 // if (target == 6) { // page7Show(); // } // 鏇存柊娴忚鍣ㄥ彸渚ч€変腑 setTimeout(function() { $fixedViewIco.removeClass("cur").eq(target).addClass("cur"); }, 400); curIndex = target; }; // viewport鍑哄幓 function viewportOut(viewportIndex, direction) { var viewportMarginTop, $viewport = $viewportCont.eq(viewportIndex), $children = $viewport.data("children"); // len = $children.length; // 鍒ゆ柇indexWrap鏄悜涓婅繕鏄悜涓嬫粴鍔 down 鍚戜笅婊? up鍚戜笂婊 viewportMarginTop = (direction == "down" ? "-" : "+") + "=150"; $viewport.stop().animate({"margin-top": viewportMarginTop}, 800, 'easeInOutCubic'); // 瀛愬厓绱犵Щ鍔 // $children.each(function() { // var targetTop = direction == "down" ? -(len - $(this).index())*150 : ($(this).index() + 1)*150; // // $(this).stop().animate({"top": targetTop}, 800, 'easeInOutCubic', function() { // $(this).css("top", 0); // }); // }); }; // viewport杩涙潵 function viewportIn(viewportIndex, direction) { var viewportMarginTop, $viewport = $viewportCont.eq(viewportIndex), $children = $viewport.data("children"); // len = $children.length; // 鍒ゆ柇indexWrap鏄悜涓婅繕鏄悜涓嬫粴鍔 down 鍚戜笅婊? up鍚戜笂婊 if (direction == "down") { viewportMarginTop = "-=150"; viewportInitMarginTop = $viewport.data("defaultMarginTop") + 150; } else { viewportMarginTop = "+=150"; viewportInitMarginTop = $viewport.data("defaultMarginTop") - 150; }; // 婊氬姩indexWrap $indexWrap.stop().animate({"scrollTop": viewportIndex * viewportHeight}, 1200, 'easeInOutCubic'); // 鍒濆鍖?viewport 骞惰繍鍔 $viewport.css("margin-top", viewportInitMarginTop).stop().delay(380).animate({"margin-top": viewportMarginTop}, 800, 'easeInOutCubic', function() { canMousewheel = true; }); // 鍒濆鍖栧瓙鍏冪礌骞惰繍鍔 // $children.each(function(index) { // $(this).css("top", function(index) { // return (direction == "down" ? index * 150 : -index*150); // }).stop().delay(380).animate({"top": 0}, 800, 'easeInOutCubic') // }); }; // 榧犳爣婊氬姩浜嬩欢 function fnMousewheel(e) { var direction, e = e || event; if (!canMousewheel) { return; } clearTimeout(lazyScroll); // 鑾峰彇婊氳疆鏂瑰悜 if (e.wheelDelta) {//IE/Opera/Chrome direction = e.wheelDelta; } else if (e.detail) {//Firefox direction = e.detail * (-1); } lazyScroll = setTimeout(function() { // 鍒ゆ柇婊氬姩鏂瑰悜 if (direction < 0) { viewportGo(curIndex + 1); } else { viewportGo(curIndex - 1); } }, 100); } // 鍒濆鍖栭〉闈 var $viewNext = $(".view-next"), $viewPrev = $(".view-prev"), $overviewView = $(".overview-view"), $historyView = $(".history-view"); $(".view-bg").find("img").css("margin", 0); function initViewport() { if( viewportHeight <= 768){ $viewportCont.find(".wrapper").css({"margin-top":"0px"}); $viewportCont.find(".con-index").css({"padding-top":"0"}); $viewportCont.find(".index-fiv-box").css({"margin-top":"50px"}); } else { $viewportCont.find(".wrapper").css({"margin-top":"0px"}); $viewportCont.find(".con-index").css({"padding-top":"40px"}); $viewportCont.find(".index-fiv-box").css({"margin-top":"150px"}); } $indexWrap.css({"overflow": "hidden", "height": viewportHeight}); $indexWrap.scrollTop(curIndex*viewportHeight); $(".viewport").css("overflow", "hidden"); $fixedViewIco.eq(curIndex).addClass("cur"); imgFull($(".view-bg")); // $(".banner").height(viewportHeight-170); // imgFull($(".banner")); page1Show(); } initViewport(); // 鍒濆鍖栫紦瀛 $viewportCont.each(function() { // 淇濆瓨榛樿鐨刴argin-top锛岀紦瀛榗hildren() var defaultMarginTop = parseInt($(this).css("margin-top")), $children = $(this).children(); $(this).data({"defaultMarginTop": defaultMarginTop, "children": $children}); //$children.css({"position": "relative"}); }); // 鍙充晶灏忕偣缁戝畾鐐瑰嚮浜嬩欢 $fixedViewIco.on("click", function() { var index = $(this).index(); viewportGo(index); }); // 涓嬩竴灞忔寜閽坊鍔犱簨浠 $(".view-next").each(function(index) { $(this).on("click", function() { viewportGo(index+1); }); }); // 涓婁竴灞忔寜閽坊鍔犱簨浠 $(".view-prev").each(function(index) { $(this).on("click", function() { viewportGo(index); }); }); $(".view-last").each(function(index) { $(this).on("click", function() { viewportGo(index); }); }); //缁戝畾婊氳疆浜嬩欢 if ($indexWrap[0].addEventListener) {//ff3.5浠ヤ笅 $indexWrap[0].addEventListener("DOMMouseScroll", function(e) { fnMousewheel(e); }, false); } $indexWrap[0].onmousewheel = function(e) { fnMousewheel(e); }; // 榛樿杩涘叆椤甸潰鍋滅暀浣嶇疆 (function() { curIndex = parseInt(location.hash.split("=")[1]) || 0; $indexWrap.scrollTop(curIndex*viewportHeight); $fixedViewIco.removeClass("cur").eq(curIndex).addClass("cur"); if (curIndex > 0) { packupHeader(); } })(); // 鏀瑰彉绐楀彛澶у皬浜嬩欢 $(window).on("resize", function() { viewportHeight = $(window).height(); initViewport(); //$(".banner").height(viewportHeight-170); //window.location.reload(); }); $("#overviewGoNext").on("click", function() { viewportGo(1); }); }); /****************************************** *** *** *** 椤甸潰鏁堟灉 *** *** *** ******************************************/ function page1Show(){ // $(".index-index .product").delay(200).animate({ // top: "0px", // opacity: 1 // },600) // // $(".index-index .slogan").delay(600).animate({ // top: "320px", // opacity: 1 // },600) // // setTimeout(function(){ // Enter($(".index-index .txt").children().eq(0), "top", 0, 3, 600, 200); // },1000) } function page2Show(){ } function page3Show(){ setTimeout(function(){ Enter($(".list-news").children().eq(0), "top", 0, 3, 600, 200); },800) } function page4Show(){ setTimeout(function(){ Enter($(".list-cats").children().eq(0), "top", 0, 5, 600, 200); },800) } function page5Show(){ setTimeout(function(){ $(".index-th .box1").delay(200).animate({ top: "0px", opacity: 1 },600) $(".index-th .box2").delay(600).animate({ top: "100px", opacity: 1 },600) },800) } function page6Show(){ } function opacityOne(obj, time, delay){ obj.stop().animate({opacity : 1}, time, "linear") setTimeout(function(){ if(obj.next()){ opacityOne(obj.next(), time, delay) } }, delay) }