$(function(){ substartJs(); subTopJs(); m21(); }); //메뉴 /*$(function(){ var marker = $('#nav .bar'), current = $('#nav .depth1.on'); menuList = $('#nav .depth1'); current.addClass('active'); marker.css({ left: current.position().left, width: current.outerWidth(), display: "block" }); $('#nav .depth1').mouseover(function () { var self = $(this), offsetLeft = self.position().left, width = self.outerWidth() || current.outerWidth(), left = offsetLeft == 0 ? 0 : offsetLeft || current.position().left; $('#nav .depth1').removeClass('active'); self.addClass('active'); marker.stop().animate({ left: left, width: width, }, 700); }); // When the mouse leaves the menu $('#nav').mouseleave(function () { $('.active').removeClass('active'); current.addClass('active'); marker.stop().animate({ left: current.position().left, width: current.outerWidth() }, 700); }); });*/ //기본js function substartJs(){ /* scroll */ var $animation_elements = $('.ani'); var $window = $(window); function check_if_in_view() { var window_height = $window.height(); var window_top_position = $window.scrollTop(); var window_bottom_position = (window_top_position + window_height); $.each($animation_elements, function() { var $element = $(this); var element_height = $element.outerHeight(); var element_top_position = $element.offset().top+150; var element_bottom_position = (element_top_position + element_height); //console.log(element_top_position); //check to see if this current container is within viewport if ((element_bottom_position >= window_top_position) && (element_top_position <= window_bottom_position)) { $element.addClass('in-view'); } else { //$element.removeClass('in-view'); } }); } $window.on('scroll resize', check_if_in_view); $window.trigger('scroll'); } function subTopJs(){ //subtop main title var animatedText = $("#main_title").text().split(""); $("#main_title").empty(); $.each(animatedText, function(i, v) { $("#main_title").append($("").text(v)); }); var numSpans = $("#main_title span").length; for (i = 0; i <= numSpans; i++) { $("#main_title span:nth-child(" + i + ")"); } $("#contents").addClass('motion'); setTimeout(function() { $("#contents").removeClass('motion'); $("#contents").removeClass('ani'); }, 2500); setTimeout(function() { $("#main_title, #subtop .g_title").addClass('on'); }, 100); //subtop 클래스 모션 $(window).scroll(function(){ var scrollT=$(window).scrollTop(); if(scrollT>280){ $('#wrap').addClass('on'); $('header').fadeOut(700); }else{ $('#wrap').removeClass('on'); $('header').fadeIn(700); } }); //visual height 모바일 높이 대응 function resetHeight(){ $('div.sub_top_wrap').css('height', $(window).innerHeight()); } window.addEventListener("resize", resetHeight); resetHeight(); //subtop 스크롤 시 투명도조절 var subBg = $('.sub_bg'); var subTopBgHeight = subBg.outerHeight(); var subTopBgOffsetTop = $('.sub_bg').offset().top; var mainOffsetTop = $('#main').offset().top; /* if(subTopBgOffsetTop >= mainOffsetTop){ subBg.css('opacity', 0); };*/ $(document).scroll(function(){ var scroll = $(window).scrollTop(); var scrollPercent = (subTopBgHeight - window.pageYOffset) / subTopBgHeight; if(scrollPercent >= 0){ //subBg.css('opacity', scrollPercent); subBg.css({ transform: 'scale('+(100 + scroll/100)/100+') rotate(0.001deg)'}); $('header').removeClass('fix'); }else{ //subBg.css('opacity', 0); $('header').addClass('fix'); } }); //subtop 스크롤 down버튼 클릭시 $('.scroll_down').on('click', function(){ var id = $(this).attr('href'), target = this.hash; $('html, body').animate({ scrollTop: $(id).offset().top }, { duration: 700, complete: function() { $(document).on("scroll", scroll); } }); return false; }); //subtop 스크롤 내릴시 $(".sub_top_wrap").on("mousewheel DOMMouseScroll", function (e) { e.preventDefault(); var delta = 0; if (!event) event = window.event; if (event.wheelDelta) { delta = event.wheelDelta / 120; if (window.opera) delta = -delta; } else if (event.detail) delta = -event.detail / 3; var moveTop = null; if (delta < 0) { if ($(this).next() != undefined) { moveTop = $(this).next().offset().top; } } else { if ($(this).prev() != undefined) { moveTop = $(this).prev().offset().top; } } $("html,body").stop().animate({ scrollTop: moveTop + 'px' }, { duration: 800, complete: function () { } }); }); } function m21(){ if(!$('#main').is('.m21')) return; $('.gallery_slider').slick({ fade: true, autoplay:true, infinite: false, autoplaySpeed:5500, adaptiveHeight: true, prevArrow: $('.gallery_slider_g').find('.prev'), nextArrow: $('.gallery_slider_g').find('.next'), pauseOnHover:false, pauseOnFocus:false, cssEase:'linear', dots: false, centerMode: true, }); $('.gallery_pager .total').text($('.gallery_slider .item').length); $('.gallery_slider').on('beforeChange', function(event, slick, currentSlide, nextSlide){ $('.gallery_pager .now').text(nextSlide+1); }); }