"use strict"; if ($("#indexBannerVideo").length && !isMobile) { var bannerVideo = videojs("indexBannerVideo"); bannerVideo.play(); } else { $("#indexBannerVideo").remove(); } // 棣栭〉瑙嗛鏂囧瓧杞挱 var homeBannerText = $('body[data-page="index"] .banner .banner-text'); var homeBannerInterval = parseInt(homeBannerText.attr("data-interval"), 10); setInterval(changeBannerText, homeBannerInterval); function changeBannerText() { var texts = homeBannerText.find("> div"); var active = homeBannerText.find("> div.active"); if (active.next().length) { texts.eq(active.index() + 1).addClass("active").siblings().removeClass("active"); } else { texts.eq(0).addClass("active").siblings().removeClass("active"); } } setBannerVideo(); // 棣栭〉杞挱 var homeSwiper; if ($(".banner .swiper-container").length) { homeSwiper = new (window.Swiper3 || Swiper)(".banner .swiper-container", { pagination: ".banner .swiper-pagination", loop: true, grabCursor: true, effect: "fade", paginationClickable: true, autoplay: 6500, speed: 800 }); } // 棣栭〉绉诲姩绔疆鎾 if (window.Swiper3) { $(".mobile-banner").css({ height: $(window).width() / (375 / 375) }); var swiper = new Swiper3("#home-banner-swiper", { pagination: ".mobile-banner .swiper-pagination", paginationClickable: ".mobile-banner .swiper-pagination", spaceBetween: 0, effect: "fade", autoplayDisableOnInteraction: false, autoplay: 5000, speed: 600, loop: true }); } // 璁剧疆banner video $(window).on("scroll", setBannerVideo); $(window).on("resize", setBannerVideo); setBannerVideo(); setTimeout(function () { setBannerVideo(); }); function setBannerVideo() { var ww = $(window).width(); var video = $('body[data-page="index"] .banner .video'); if (ww < 1200) { ww = 1200; } video.outerWidth(ww); video.find(".video-element").css({ // left: (ww - 1920) / 2 }); // $(".banner-container .banner").height($(window).height()); if (homeSwiper) { homeSwiper.resizeFix && homeSwiper.resizeFix(); homeSwiper.update && homeSwiper.update(); } } // test var pageIndex = 0; var prePageIndex; var scrolling = false; var scrollingSt; var parts = $(".parts .part"); if (!isMobile) { var debounceNextPage; var debouncePrevPage; var prevY; var startY; var endY; (function () { var setPart = function setPart() { $(".parts").height($(window).height()); parts.height($(window).height()); var scale = $(window).width() / 2560; if (scale > 1) { scale = 1; } $(".part__box").css({ top: -$(window).height() * pageIndex }); ifBlack(); }; var ifBlack = function ifBlack() { if (pageIndex !== 0) { $(".header, .mobile-header").addClass("black"); } else { $(".header, .mobile-header").removeClass("black"); } }; var jumpPage = function jumpPage() { scrolling = true; clearTimeout(scrollingSt); scrollingSt = setTimeout(function () { scrolling = false; }, 400); if (pageIndex === 1 && prePageIndex !== parts.length - 1) { $("*[count-up-to-p]").each(function () { $(this).html($(this).attr("count-up-to-p")); if ($(this).data("countup")) { $(this).data("countup").pauseResume(); } // setTimeout(() => { // const to = parseInt($(this).attr("count-up-to-p")); window.counterUp["default"](this, { duration: 3000, delay: 50 }); // const countUp = new CountUp(this, to, { // separator: "", // }); // $(this).data("countup", countUp); // if (!countUp.error) { // countUp.start(); // } else { // console.error(countUp.error); // } // }, 50); }); } if (pageIndex === parts.length - 1) { $(".part__box").stop(true).animate({ top: -$(window).height() * (pageIndex - 1) - $(".footer").outerHeight() }, 400); } else { $(".part__box").stop(true).animate({ top: -$(window).height() * pageIndex }, 400); } ifBlack(); updatePageAnimate(); }; var nextPage = function nextPage() { var isClick = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; if (pageIndex < parts.length - 1 && (!scrolling || isClick)) { prePageIndex = pageIndex; pageIndex++; jumpPage(); } }; var prevPage = function prevPage() { var isClick = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; if (pageIndex > 0 && (!scrolling || isClick)) { prePageIndex = pageIndex; pageIndex--; jumpPage(); } }; var updatePageAnimate = function updatePageAnimate() { if (pageIndex === 0 || pageIndex === parts.length - 1 || prePageIndex === parts.length - 1) { setTimeout(function () { updateAnimate(); }, 50); return; } setTimeout(function () { $(".part").eq(pageIndex).find(".show-in, .fade-in, .blur-in, .scale-in, .fade-in-up, .fade-in-left, .fade-in-left-long, .fade-in-right, .fade-in-down").each(function () { $(this).removeClass("show").attr("data-faded", ""); }); }, 50); setTimeout(function () { updateAnimate(); }, 500); }; $(window).on("resize", function () { setPart(); }); setPart(); debounceNextPage = $.debounce(150, nextPage); debouncePrevPage = $.debounce(150, prevPage); prevY = false; $(document).on("mousewheel", function (event) { var y = event.deltaY; if ($(event.target).hasClass(".business__desc") || $(event.target).parents(".business__desc").length) { return; } if (y > 0) { if (prevY !== false && (isMac ? prevY < y : prevY <= y)) { debouncePrevPage(); } } if (y < 0) { if (prevY !== false && (isMac ? prevY > y : prevY >= y)) { debounceNextPage(); } } prevY = y; }); $(document).on("keyup", function (e) { if (e.keyCode === 38) { prevPage(true); } if (e.keyCode === 40) { nextPage(true); } }); $(".parts").on("touchstart", function (e) { if ($(e.target).hasClass("prev") || $(e.target).hasClass("next") || $(e.target).attr("href")) {} else { e.preventDefault(); } startY = e.originalEvent.touches[0].pageY; endY = startY; }); $(".parts").on("touchmove", function (e) { endY = e.originalEvent.touches[0].pageY; }); $(".parts").on("touchend", function (e) { if (startY - endY > 30) { nextPage(); } if (startY - endY < -30) { prevPage(); } }); $(".controls .prev").click(function () { prevPage(true); }); $(".controls .next").click(function () { nextPage(true); }); if (isMobile) { $("body[data-page=index] .parts .part.p1 .next").hammer().on("tap", function () { nextPage(true); }); } else { $("body[data-page=index] .parts .part.p1 .next").click(function () { nextPage(true); }); } })(); } var p4swiper = new (window.Swiper3 || Swiper)(".p4 .swiper-container", { pagination: ".p4 .swiper-pagination", loop: true, // grabCursor: true, // effect: "fade", paginationClickable: true, // autoplay: 6000, speed: 800 }); $(".p4 .pagination .prev").on("click", function () { p4swiper.slidePrev && p4swiper.slidePrev(); p4swiper.swipePrev && p4swiper.swipePrev(); }); $(".p4 .pagination .next").on("click", function () { p4swiper.slideNext && p4swiper.slideNext(); p4swiper.swipeNext && p4swiper.swipeNext(); }); var p5swiper = new (window.Swiper3 || Swiper)(".p5 .swiper-container", { pagination: ".p5 .swiper-pagination", // loop: true, // grabCursor: true, // effect: "fade", paginationClickable: true, slidesPerView: isMobile ? 1 : 3, onSlideChangeEnd: function onSlideChangeEnd() { checkArrow(); } }); // autoplay: 6000, // speed: 800, function checkArrow() { if (p5swiper) { var max = p5swiper.slides.length - (isMobile ? 1 : 3); if (p5swiper.activeIndex === 0 && max === 0) { $(".p5 .pagination").hide(); } else if (p5swiper.activeIndex === 0) { $(".p5 .prev").css("opacity", 0); $(".p5 .next").css("opacity", 1); } else if (p5swiper.activeIndex === max) { $(".p5 .prev").css("opacity", 1); $(".p5 .next").css("opacity", 0); } else { $(".p5 .prev").css("opacity", 1); $(".p5 .next").css("opacity", 1); } } } $(".p5 .pagination .prev").on("click", function () { p5swiper.slidePrev && p5swiper.slidePrev(); p5swiper.swipePrev && p5swiper.swipePrev(); }); $(".p5 .pagination .next").on("click", function () { p5swiper.slideNext && p5swiper.slideNext(); p5swiper.swipeNext && p5swiper.swipeNext(); });