/*-------------------------------------------*/ /* MAINV SLIDER /*-------------------------------------------*/ function mainvSlick() { $('.mainv-slide-list').slick({ autoplay: true, autoplaySpeed: 3000, speed: 3000, slidesToShow: 1, pauseOnFocus: false, pauseOnHover: false, pauseOnDotsHover: false, waitForAnimate: false, dots: true, fade: true, arrows: false, }); }; /*-------------------------------------------*/ /* LOAD /*-------------------------------------------*/ $(window).on('load', function () { $('#load div.inner').delay(300).fadeOut(500); $('#load').delay(800).fadeOut(800); setTimeout(mainvSlick, 1550); }); $(function () { $('.mainv-slide-list').on('touchmove', function (event, slick, currentSlide, nextSlide) { $('.mainv-slide-list').slick('slickPlay'); }); /*-------------------------------------------*/ /* SLIDER /*-------------------------------------------*/ $('.factory-slide-list').slick({ autoplay: true, autoplaySpeed: 3000, speed: 1000, slidesToShow: 1, pauseOnHover: false, pauseOnFocus: false, dots: false, centerMode: true, variableHeight: true, variableWidth: true, arrows: false, }); $('.products-slide-list.odd').slick({ autoplay: true, autoplaySpeed: 3000, speed: 1000, slidesToShow: 1, pauseOnHover: false, pauseOnFocus: false, dots: false, fade: true, arrows: true, prevArrow: '', nextArrow: '', }); $('.products-slide-list.even').slick({ autoplay: true, autoplaySpeed: 5000, speed: 1000, slidesToShow: 1, pauseOnHover: false, pauseOnFocus: false, dots: false, fade: true, arrows: true, prevArrow: '', nextArrow: '', }); /*-------------------------------------------*/ /* MAINV SETUP HEIGHT /*-------------------------------------------*/ setUpHeight(); function setUpHeight() { let $windowHeight = $(window).height(); let $windowWidth = $(window).width(); let headerHeight = 65; if ($windowWidth > 999) { $('.mainv .wrapper , .mainv-slide-list .item').css('height', $windowHeight + 'px'); } else { $windowHeight = $windowHeight - headerHeight; $('.mainv .wrapper , .mainv-slide-list .item').css('height', $windowHeight + 'px'); } }; /*-------------------------------------------*/ /* INVIEW /*-------------------------------------------*/ $('.come-to-view').on('inview', function (event, isInView) { if (isInView) { $(this).stop().addClass("inview"); } }); // /*-------------------------------------------*/ // /* SMOOTHSCROll // /*-------------------------------------------*/ // //on click let anchorClassInMobileMenu = '.sp-menu a.link[href^="#"]' $('a[href^="#"]').click(function (ev) { if ($(this).parents(".sp-menu").length > 0) { ev.preventDefault() location.hash = this.hash let that = this setTimeout(function () { smoothScroll(that.hash); }, 50) } else { smoothScroll(this.hash); } }); //on load if (location.hash !== "") { smoothScroll(location.hash); } // @param { string } hash function smoothScroll(hash) { let $toItem = $(hash); let hashOffset = $toItem.offset().top; let $windowWidth = $(window).width(); let Adjuster = 0; if ($windowWidth > 999) { Adjuster = 0; } else { Adjuster = 60; } let scrollTop = hashOffset - Adjuster $("html,body").animate({ scrollTop: scrollTop }, 700, "swing"); return false; } // /*-------------------------------------------*/ // /* DRAWER MENU // /*-------------------------------------------*/ //on click $('#switch,' + anchorClassInMobileMenu).click(function () { drawerMenu(); bodyFix(); }); let scrollpos = 0 function bodyFix() { if ($('body').hasClass('fixed')) { $('body').removeClass('fixed').css({ 'top': 0 }); window.scrollTo(0, scrollpos); } else { scrollpos = $(window).scrollTop(); $('body').addClass('fixed').css({ 'top': -scrollpos }); } } function drawerMenu() { $('#salesatei, #switch').toggleClass('open'); let $windowWidth = $(window).width(); if ($windowWidth < 999) { $('.sp-menu').fadeToggle(300); } if ($('#switch').hasClass('open')) { $('.sp-menu-text').text('CLOSE'); } else { $('.sp-menu-text').text('MENU'); } if ($('.salesatei').hasClass('scroll')) { $('.salesatei').css('display', 'block'); } }; /*-------------------------------------------*/ /* SPMENU REMOVE CLASS /*-------------------------------------------*/ spStyleSetUp(); function spStyleSetUp() { let $windowWidth = $(window).width(); if (($windowWidth > 999)) { $('.sp-menu').css('display', 'block'); } else if (!($('#salesatei').hasClass('open'))) { $('.sp-menu').fadeOut(0); } }; /*-------------------------------------------*/ /* CURRENT SECTION MARKE /*-------------------------------------------*/ $(window).on('resize scroll', function () { if (!($('body').hasClass('fixed'))) { var nY = $(window).scrollTop(); //LastSection let $pageHeihgt = $(document).innerHeight(); let $winHeight = $(window).innerHeight(); let $posContact = $pageHeihgt - $winHeight; var nP = [0, $("#about").offset().top, $("#factory").offset().top, $("#products").offset().top, $("#company").offset().top, $posContact]; $(".header-navi .item .link.current").removeClass("current"); if (nP[1] - 150 > nY) { var nN = 0; } else if (nP[5] - 150 <= nY) { var nN = 5; } else { for (i = 1; i < 6; i++) { if (nP[i] - 150 <= nY && nP[i + 1] - 150 > nY) { var nN = i; } } } var nC = ".item .link.navi" + nN; $(nC).addClass("current"); } }); let timer = 0; $(window).resize(function () { spStyleSetUp(); if (timer > 0) { clearTimeout(timer); } timer = setTimeout(function () { setUpHeight(); }, 300); }); let slickReinitTimer = 0; $(window).resize(function () { if (slickReinitTimer > 0) { clearTimeout(slickReinitTimer); } slickReinitTimer = setTimeout(function () { $('.item-slide').slick('reinit'); }, 1000); }); });