/*-------------------------------------- 비즈마루 테마 스크립트 --------------------------------------*/ /* INTRO SCROLL DOWN */ $(function() { $('.scroll-down').on('click', function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: $($(this).attr('href')).offset().top}, 600); }); }); /* SIDE PAGE SLIDER */ class StickyNavigation { constructor() { this.currentId = null; this.currentTab = null; this.tabContainerHeight = 0; let self = this; $('.et-hero-tab').click(function() { self.onTabClick(event, $(this)); }); $(window).scroll(() => { this.onScroll(); }); $(window).resize(() => { this.onResize(); }); this.setSliderCss(); } onTabClick(event, element) { let idx = element.context.dataset.idx; event.preventDefault(); let scrollTop = $(element.attr('href')).offset().top; $('html, body').animate({ scrollTop: scrollTop }, 600); //메뉴 비활성화.. $('.mobile-nav-open').removeClass('active'); $('.et-hero-tabs-container').removeClass('active'); this.setSliderCss(element); } onScroll() { // this.checkTabContainerPosition(); this.findCurrentTabSelector(); } onResize() { if(this.currentTab) { this.setSliderCss(this.currentTab); } } checkTabContainerPosition() { let offset = $('.et-hero-tabs').offset().top; if($(window).scrollTop() > offset + 600) { $('.et-hero-tabs-container').addClass('et-hero-tabs-container--top'); } else { $('.et-hero-tabs-container').removeClass('et-hero-tabs-container--top'); } } findCurrentTabSelector(element) { let newCurrentId; let newCurrentTab; let self = this; $('.et-hero-tab').each(function() { let id = $(this).attr('href'); let offsetTop = $(id).offset().top; let offsetBottom = $(id).offset().top + $(id).height(); if($(window).scrollTop() > offsetTop && $(window).scrollTop() < offsetBottom) { newCurrentId = id; newCurrentTab = $(this); } }); if(this.currentId != newCurrentId || this.currentId === null) { this.currentId = newCurrentId; this.currentTab = newCurrentTab; this.setSliderCss(this.currentTab); } } setSliderCss(element) { let height = 0; let top = 0; if(!element) { if(this.currentTab) { height = this.currentTab.css('height'); top = this.currentTab.offset().top; } }else{ let idx = element.context.dataset.idx; top = top * ( idx - 1 ) ; } $('.et-hero-tab-slider').css('height', height); $('.et-hero-tab-slider').css('top', top); } } function initStickyNav() { new StickyNavigation(); } $(document).ready( function () { window.setTimeout(initStickyNav,100); }); /* SIDE NAVIGATION ACTIVE */ $('.et-hero-tab').click(function() { $('.et-hero-tab').removeClass('active'); $(this).addClass('active'); }); /* MOBILE SIDE NAVIGATION ACTIVE */ $(function() { var openButton = $('.mobile-nav-open'); var idx = 0; openButton.click(function() { if(idx == 0) { $('.et-hero-tabs-container').addClass('active'); openButton.addClass('active'); idx = 1; } else if(idx == 1) { $('.et-hero-tabs-container').removeClass('active'); openButton.removeClass('active'); idx = 0; } }); }); /* 비즈마루 이동 버튼 */ $("#tab-bizmaru").click(function() { var scrollPosition = $(document).height(); $("html, body").animate({ scrollTop: scrollPosition }, 500); }); /* 비즈마루 소개 하단 이벤트 */ $(window).scroll(function() { var scrollHeight = $(document).height(); var scrollPosition = $(window).height() + $(window).scrollTop(); if ((scrollHeight - scrollPosition) / scrollHeight === 0) { $(".end-section").css('z-index', 1); $(".end-section").css('opacity', 1); } else { $(".end-section").css('z-index', -1); $(".end-section").css('opacity', 0.7); } });