$(function(){ popup(); /* 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+200; 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'); //모션 시작 class $("body").addClass("motion"); //section2 스크롤 이동 $(".section1 .scroll_btn").click(function(){ var mainHgt = $(".section1").height(); gsap.to(window, {duration: .4,scrollTo:mainHgt,ease: 'power3.out'}); }); //메인 background 슬라이드 var mainVisualSwiper = new Swiper('.main_visual_bg_slider', { effect:'fade', watchSlidesProgress: true, allowTouchMove:false, }); //메인 타이틀 슬라이드 var mainTitleSwiper = new Swiper('.main_visual_tit_slider', { effect:'fade', /*autoplay: { delay: 5000, disableOnInteraction: false, },*/ loop:true, pagination: { el: '.main_pagination', }, navigation: { nextEl: ".main_next", prevEl: ".main_prev", }, thumbs: { swiper: mainVisualSwiper, }, allowTouchMove:false, }); $('.ani_y').each(function(){ var $this = $(this); gsap.fromTo($this,{ opacity: 0, y: 100, },{ opacity: 1, y: 0, duration: 1, scrollTrigger: { trigger: $this, start: 'top 80%', }, ease: 'power2.out', }); }); }); function popup(){ // 레이어팝업 var bg = $("#bg"); $(document).on('click',' #bg, .close ', function () { bg.fadeOut(); $('#video-popup div.inner').html(''); $('#video-popup').hide(); }); $('.play_btn').on('click', function(){ var dataUrl = $(this).attr('data-url'); if(dataUrl){ bg.show(); $('#video-popup').show(); $('#video-popup').html( ''+ '
'+ '
' ); $('#video-popup div.inner').html(dataUrl); }else { alert('준비중 입니다.'); } }); }