var CJFRESHWAY_MAIN = (function () { var $window = $(window); var currentRollingIdx = 0; var rollingDelay = 5000; var prevRollingIdx = -1, heightGap = 100; var nextRollingIdx = currentRollingIdx +1; var $rollingSection = $('.section.main .video_container .video_wrap'); var $rollingStep = $('.section.main .video_step_wrap .video_step li'); var circle1,circle2,circle3,circle4, circleArr = [], circleIndex = 0; var isMainRolling = false, isMainTweening = false; var isVrOn = false; var cookiedata1 = getCookie("saw_pop01"); function init(){ setEvent(); mainInMotion(); EventDispatcher.add(this, Events.STARTMAINTOP, tweenResume); EventDispatcher.add(this, Events.STOPMAINTOP, tweenPause); } var $title = $('.main .video_container .video_wrap.first .copy_container h2 em'); function textSetMotion(){ $title.each(function(i,t){ TweenMax.set($(this),{x:(50)}) }); } function textInMotion(){ $title.each(function(i,t){ TweenMax.to($(this),0.8,{delay:i*0.05+0,x:0,opacity:1,ease:Cubic.easeOut}) }); } textSetMotion(); function setCookie(name, value, expirehours){ var todayDate = new Date(); todayDate.setHours(todayDate.getHours() + expirehours); document.cookie = name + "=" + escape(value) + ";path=/;expires=" + todayDate.toGMTString() + ";"; } function getCookie(name){ var cookiedata = document.cookie; var index = cookiedata.indexOf(name + "="); if(index == -1) return null; index = cookiedata.indexOf("=", index) + 1; var endstr = cookiedata.indexOf(";", index); if(endstr == -1) endstr = cookiedata.length; return unescape(cookiedata.substring(index, endstr)); } function mainInMotion(){ $('.dimmed').addClass('on'); circle1 = new CirCleProgress('circle_canvas1', rollingDelay, 100, circleCallback, true, 0); circle2 = new CirCleProgress('circle_canvas2', rollingDelay, 100, circleCallback, true, 1); circle3 = new CirCleProgress('circle_canvas3', rollingDelay, 100, circleCallback, true, 2); circle4 = new CirCleProgress('circle_canvas4', rollingDelay, 100, circleCallback, true, 3); circleArr = [circle1, circle2, circle3, circle4]; TweenMax.fromTo($('#gnb'), 0.6,{marginTop:-70},{marginTop:0, delay:0.3, onComplete: function(){ $('.dimmed').remove(); TweenMax.to($('.video_step li:eq(0)'), 0.4, {opacity:1}); TweenMax.to($('.video_step li:eq(1)'), 0.4, {opacity:1,delay:0.1}); TweenMax.to($('.video_step li:eq(2)'), 0.4, {opacity:1,delay:0.3}); TweenMax.to($('.video_step li:eq(3)'), 0.4, {opacity:1,delay:0.5}); textInMotion(); $('.copy_container').addClass('on'); setRollingCircle(); if(getURLParameter('cs')=='true'){ $('#gnb .navi .btn_inquiry >a').click(); } }}); } function setRollingCircle(){ isMainRolling = true; circleArr[0].start(); $rollingStep.eq(circleIndex).addClass('on'); $rollingSection.eq(currentRollingIdx).addClass('on motion'); $rollingSection.eq(currentRollingIdx).find('video')[0].play(); } function circleCallback(){ circleIndex++; if(circleIndex > circleArr.length -1){ circleIndex = 0; } mainVideoRolling(circleIndex); $rollingStep.removeClass('on'); $rollingStep.eq(circleIndex).addClass('on'); circleArr[circleIndex].start(); } function tweenPause(){ try{ if(!isMainRolling){return;} isMainRolling = false; stopAllVideo(); circleArr[circleIndex].stop(); }catch (e){} } function tweenResume(){ try{ if(isVrOn){return;} if(isMainRolling){return;} isMainRolling = true; $rollingSection.eq(circleIndex).find('video')[0].currentTime = 0; $rollingSection.eq(circleIndex).find('video')[0].play(); circleArr[circleIndex].start(); }catch (e){} } function setInside() { if($('.inside_area').length==0){return;} var tplThumb='',tplText='',btnPlayText=''; var _svgNS = 'http://www.w3.org/2000/svg'; var svg = document.getElementById('scale_group'); /* var clippath = document.createElementNS(_svgNS, 'clipPath'); clippath.setAttributeNS(null, 'id', 'clipCircle'); svg.appendChild(clippath); var circle = document.createElementNS(_svgNS, 'circle'); circle.setAttributeNS(null, 'r', '405'); circle.setAttributeNS(null, 'cx', '444'); circle.setAttributeNS(null, 'cy', '427'); clippath.appendChild(circle);*/ $.ajax({ url : "/inside.do", dataType : "jsonp", method : "post", success : function( data ) { $.each(data.result, function( i, val ) { var seq = val.idx ? val.idx : 0; var idx = (i+1); var image = document.createElementNS(_svgNS, 'image'); image.setAttribute("class",'inside_img'+idx); image.setAttributeNS(null,"clip-path","url(#clipCircle)"); image.setAttributeNS(null,"preserveAspectRatio","none"); image.setAttributeNS(null,"width",'888'); image.setAttributeNS(null,"height",'854'); image.setAttributeNS('http://www.w3.org/1999/xlink','href',val.img); svg.appendChild(image); tplThumb+='
  • '+idx+'
  • '; tplText+='
  • '+val.title+'”

    '+val.work.replace(/@br@/gi,' ')+'팀
    '+val.name+'
  • '; btnPlayText+='재생'; }); $('.inside_area .circle_area .btn_play').html(btnPlayText); $('.inside_area .title_wrap.right .thumb ul').html(tplThumb); $('.inside_area .section_inner .title_wrap.right .text_area ul').html(tplText); } }); } function setNow() { if($('.now_area').length==0){return;} var tpl='',tplCarousel=''; $.ajax({ url : "/now.do", dataType : "jsonp", method : "post", success : function( data ) { $.each(data.result, function( i, val ) { if(val.thumbType=='image'){ tpl+='
  • '; tpl+=''; tpl+=''+val.title+''; tpl+='
    '; tpl+=''+val.newsType+''; tpl+=''+val.title+''; tpl+=''+val.date+''; tpl+='
    '; tpl+='
    '; tpl+='
  • '; }else { tpl+='
  • '; tpl+=''; tpl+='
    '; tpl+=''+val.text+''; tpl+=''+val.title+''; tpl+=''+val.date+''; tpl+='
    '; tpl+='
    '; tpl+='
  • '; } }); var clen = Math.ceil(data.result.length/3); for(var i=0;i'+idx+''; } if(clen>0){ $('.section.others .now_area .section_inner .slide_area .carousel ul').html(tplCarousel); } $('.section.others .now_area .section_inner .slide_area .slide_inner ul').css('width',978*clen).html(tpl); },error:function(data){ console.log(data); } }); } function setEvent(){ setInside();setNow(); scrollEvent(); $('.layerPopup .layerToday input[type="checkbox"]').click(function(){ if($(this).prop("checked")==true){ setCookie('saw_pop01',true,24); }else{ setCookie("saw_pop01","",-1); } }); $('.video_step li a').on('click', function(e){ e.preventDefault(); var idx = $(this).parent().index(); if(isMainTweening){return;} if($rollingStep.eq(idx).hasClass('on')){return;} $rollingStep.removeClass('on'); circleArr[circleIndex].stop(); $rollingStep.eq(idx).addClass('on'); circleArr[idx].start(); circleIndex = idx; mainVideoRolling(idx); }); $(document).on('click','.inside_area .thumb ul li a', function(e){ e.preventDefault(); var idx = $(this).parent().index(); $(this).parents('.section_inner').attr('data-num',idx); }); $(document).on('click','.slide_area .slide_inner ul li a', function(){ eventTrack('btn_more_now'); }); $(document).on('click','.circle_area .btn_play a', function(){ eventTrack('btn_more_inside'); }); $('.inside_area .btn_left').on('click', function(e){ e.preventDefault(); var len = $('.inside_area .title_wrap .thumb ul li').length; var num = parseInt($('.inside_area .section_inner').attr('data-num')); var cnt = num<=0?len-1:num-1; TweenMax.set("#clipCircle circle", {attr: { r:282}}); TweenMax.to("#clipCircle circle", 0.4, {attr: { r:320},ease: Cubic.easeInOut,onComplete:function(){ $('.inside_area .section_inner').attr('data-num',cnt); TweenMax.to("#clipCircle circle", 0.4, {attr: { r:282},ease: Cubic.easeOut}); }}); }); $('.inside_area .btn_right').on('click', function(e){ e.preventDefault(); var len = $('.inside_area .title_wrap .thumb ul li').length; var num = parseInt($('.inside_area .section_inner').attr('data-num')); var cnt = num>=len-1?0:num+1; TweenMax.set("#clipCircle circle", {attr: { r:282}}); TweenMax.to("#clipCircle circle", 0.4, {attr: { r:320},ease: Cubic.easeInOut,onComplete:function(){ $('.inside_area .section_inner').attr('data-num',cnt); TweenMax.to("#clipCircle circle", 0.4, {attr: { r:282},ease: Cubic.easeOut}); }}); }); $('.now_area .btn_left').on('click', function(e){ e.preventDefault(); var len = $('.now_area .slide_area .carousel ul li').length; var num = parseInt($('.now_area .section_inner').attr('data-num')); var cnt = num<=0?len-1:num-1; $('.now_area .section_inner').attr('data-num',cnt); TweenMax.to( $('.now_area .slide_inner ul'),0.5,{x:cnt*-978}); $('.now_area .carousel ul li').removeClass('on'); $('.now_area .carousel ul li').eq(cnt).addClass('on'); }); $('.now_area .btn_right').on('click', function(e){ e.preventDefault(); var len = $('.now_area .slide_area .carousel ul li').length; var num = parseInt($('.now_area .section_inner').attr('data-num')); var cnt = num>=len-1?0:num+1; $('.now_area .section_inner').attr('data-num',cnt); TweenMax.to( $('.now_area .slide_inner ul'),0.5,{x:cnt*-978}); $('.now_area .carousel ul li').removeClass('on'); $('.now_area .carousel ul li').eq(cnt).addClass('on'); }); $(document).on('click','.now_area .carousel ul li a', function(e){ e.preventDefault(); var idx = $(this).parent().index(); $('.now_area .carousel ul li').removeClass('on'); $(this).parent().addClass('on'); $('.now_area .section_inner').attr('data-num',idx); TweenMax.to( $('.now_area .slide_inner ul'),0.5,{x:idx*-978}); }); $('a.btn_faq').on('click', function(e){ e.preventDefault(); tweenPause(); $('.btn_inquiry').click(); }); /*vr*/ $('a.btn_vrplay').on('click', function(e){ e.preventDefault(); tweenPause(); $('#vr_container').show(); cj360.play(); isVrOn = true; }); window.addEventListener('closevr', function(e){ isVrOn = false; tweenResume(); }); } function stopAllVideo(){ $rollingSection.find('video').each(function(i,t){ var video = t; if (!video.paused) { video.pause(); video.currentTime = 0; } }); } function mainVideoRolling(_idx){ //stopAllVideo(); nextRollingIdx = prevRollingIdx; prevRollingIdx = currentRollingIdx; currentRollingIdx = _idx; $rollingSection.eq(prevRollingIdx).find('video')[0].pause(); $rollingSection.removeClass('first'); $rollingSection.eq(nextRollingIdx).removeClass('motion'); $rollingSection.eq(prevRollingIdx).removeClass('on'); $rollingSection.eq(currentRollingIdx).addClass('on motion'); $rollingSection.eq(currentRollingIdx).find('video')[0].currentTime = 0; $rollingSection.eq(currentRollingIdx).find('video')[0].play(); } function scrollEvent(){ var w = 2000;var is_slide=true $('.curve1').css("marginLeft",-w); $('.curve2').addClass('active').css("marginLeft",0); $('.curve3').css("marginLeft",w); var $overlay_b = $('.business_area ul li .overlay'); var tl_b = new TimelineLite(); tl_b.set($overlay_b, {scaleX:.05, scaleY:0,transformOrigin: "0 0",autoAlpha:1}); var $scoll = $('#contents'); var scrollTime = 0.5; var scrollDistance = 120; var scrTop = $scoll.scrollTop(); /* $window.on("mousewheel DOMMouseScroll", function(event) { event.preventDefault(); var delta = event.originalEvent.wheelDelta / 120 || -event.originalEvent.detail / 3; scrTop = scrTop - parseInt(delta * scrollDistance); scrTop = Math.max(0, Math.min($scoll[0].scrollHeight, scrTop)); TweenMax.to($scoll, scrollTime, {y: -scrTop, ease: Power1.easeOut, overwrite: 5}); });*/ $window.scroll(function(e) { var scrTop = $(window).scrollTop(); //gnb if(scrTop > $('#gnb').innerHeight()){ if (!$('#gnb').hasClass('on')) { $('#gnb').addClass('on'); } }else{ if ($('#gnb').hasClass('on')) { $('#gnb').removeClass('on'); } } var min_business = $('#contents .business_area ul').offset().top - window.innerHeight+($('#contents .business_area ul').innerHeight()/2); scrollMotion(scrTop,min_business,$('.section.others .business_area'),function(){ tweenPause(); tl_b.to($overlay_b, 0.6, {scaleY:1,ease:Cubic.easeInOut}); tl_b.to($overlay_b, 0.6, {scaleX:1,transformOrigin: "0 50%",ease:Cubic.easeInOut,onComplete:function(){ $('.business_area ul li a').css({'visibility':'visible','opacity': 1}) }}); tl_b.to($overlay_b, 0.1, {transformOrigin: "100% 50%"}); tl_b.to($overlay_b, 0.6, {scaleX:0, scaleY:1,ease:Cubic.easeInOut}); }) parallaxMotion(scrTop,min_business,min_business+50,$('.section.others .business_area'),function(per){ if(per>=1){ if(is_slide==true){ is_slide=false; tweenPause(); } }else{ if(is_slide==false) { is_slide = true; tweenResume(); } } }); scrollCheckImg(scrTop); scrollMaskImg(scrTop); var min_wave1 = $('#wave1').offset().top - window.innerHeight; var max_wave1 =min_wave1+(window.innerHeight/2); parallaxMotion(scrTop, min_wave1, max_wave1, $('#wave1'), function (per) { if ($('#wave1').hasClass('on')) { TweenMax.to($('#wave1 g'), 0.5, {x: per * 70 , ease: Quad.easeOut}); } }); var min_wave2 = $('#wave2').offset().top - window.innerHeight; var max_wave2 = min_wave2+(window.innerHeight/2); parallaxMotion(scrTop, min_wave2, max_wave2, $('#wave2'), function (per) { if ($('#wave2').hasClass('on')) { TweenMax.to( $('#wave2 g'), 0.6, {x: per *80,ease: Quad.easeOut}); } }); var min_wave3= $('#wave3').offset().top - window.innerHeight; var max_wave3 =min_wave3+(window.innerHeight/2); parallaxMotion(scrTop, min_wave3, max_wave3, $('#wave3'), function (per) { if ($('#wave3').hasClass('on')) { TweenMax.to($('#wave3 g'), 0.5, {x: per * 60, ease: Quad.easeOut}); } }); var min_wave4 = $('#wave4').offset().top -window.innerHeight; var max_wave4 =min_wave4+(window.innerHeight/2); parallaxMotion(scrTop, min_wave4, max_wave4, $('#wave4'), function (per) { if ($('#wave4').hasClass('on')) { TweenMax.to($('#wave4 g'), 0.7, {x: per * 85+20 , ease: Quad.easeOut}); } }); var min_bg= $('.section.others').offset().top -window.innerHeight; var max_bg =min_bg+$('.section.others').innerHeight(); parallaxMotion(scrTop, min_bg, max_bg, $('.section.others .bg'), function (per) { var val = 150; TweenMax.to($('.section.others .bg'), 0.6, {y: per * -150 + 100, ease: Quad.easeOut}); }); for(var i=0;i<3;i++) { var $img=$('.infra_area ul li').eq(i).find('.img'); var $text=$('.infra_area ul li').eq(i).find('.text'); var min_cha = $('.infra_area ul li').eq(i).offset().top - (window.innerHeight)+($('.infra_area ul li').innerHeight()/2); var max_cha = 100 + min_cha; parallaxMotion(scrTop, min_cha, max_cha, $img, function (per) { TweenMax.to($img, 0.5, {y: per * -500+500,ease: Quad.easeOut,force3D: true}); TweenMax.to($text, 0.5, {y: per * -300+300,ease: Quad.easeOut,force3D: true}); }); } if($('.section.others .inside_area').length>0){ var min_inside = $('.section.others .inside_area').offset().top - window.innerHeight+($('.section.others .inside_area').innerHeight()/3); var max_inside =min_inside+($('.section.others .inside_area').innerHeight()/2); parallaxMotion(scrTop, min_inside, max_inside, $('.section.others .inside_area'), function (per) { if($('.section.others .inside_area').hasClass('on')==false){ TweenMax.to("#clipCircle circle", 0.3, {attr: { r: 427*(per *-0.34+1) },ease: Quad.easeOut}); TweenMax.to($('.btn_play')[0], 0.3, {scale: per *1,transformOrigin: "50% 50%",ease: Quad.easeOut}); } if(per>=1){ $('.section.others .inside_area').addClass('on'); } }); } }); } function scrollCheckImg(_scrTop){ checkObject('.mask', _scrTop , 200); checkObject('.wave', _scrTop , 200); checkObject('.pattern', _scrTop , 200); checkObject('.section_inner .title_wrap', _scrTop , 100); checkObject('.now_area .section_inner .slide_area', _scrTop , 250); checkObject('.infra_area ul li', _scrTop , 100); checkObject('.infra_area ul li .text', _scrTop , 100); } function checkObject(_obj, _scrTop, _gap){ $(_obj).each(function (i, t) { var selfHeight = $(this).offset().top - _gap; var checkHeight = selfHeight - (window.innerHeight / 2) ; if (_scrTop > checkHeight && checkHeight > 0) { if (!$(this).hasClass('on')) { $(this).addClass('on'); } }else{ if ($(this).hasClass('on')) { /*if(_obj == '.circle'){ $(this).removeClass('on'); }*/ } } }); } function scrollMaskImg(_scrTop){ /* $('.mask').each(function (i, t) { if ($(this).hasClass('on')) { var scrTop = _scrTop / 50 * -1; TweenMax.to($(this).find('img'), 1, {y:scrTop, force3D:true}); } });*/ $('.pattern.up').each(function (i, t) { var scrTop = _scrTop / 20 * -1; TweenMax.to($(this).find('img'), 0.4, {y:scrTop, force3D:true}); }); $('.pattern.dowm').each(function (i, t) { var scrTop = _scrTop / 10 * 1; TweenMax.to($(this).find('img'), 0.2, {y:scrTop, force3D:true}); }); } function parallaxMotion( _scroll,_min, _max,_$scope,_callback){ if(_$scope.length==0){return;} var maxscroll = document.body.clientHeight-window.innerHeight; _min=(_min>maxscroll-100?maxscroll-100:_min); var per = (_scroll-_min)/((_max>maxscroll?maxscroll:_max)-_min); per = (per < 0)?0:(per>1)?1:per; if (_callback) { _callback(per); } } function scrollMotion(_scroll,_min,_$scope,_callback){ if(_scroll>=_min) { if (_callback && _$scope[0].is_play==undefined ) { _callback(); _$scope[0].is_play=true; } } } return { init: function () { init(); }, tweenPause : function(){ tweenPause(); }, tweenResume : function(){ tweenResume(); } } })(); $(function(){ CJFRESHWAY_MAIN.init(); }); ;( function(global) { function CirCleProgress(_target, _duration, _percent,_callback, _filldirection, _idx) { this.ctx = document.getElementById(_target).getContext('2d'); this.canvas = document.getElementById(_target); this.duration = _duration; this.percent = _percent; this.callback = _callback; this.filldirection = _filldirection; this.idx = _idx; this.endTime; this.diff; this.timer; this.canvas.width = 44; this.canvas.height = 44; }; CirCleProgress.prototype = { drawCircle : function(){ var self = this, ctx = self.ctx, imd, now = new Date().getTime(), remaining = Math.max((self.endTime - now) / self.duration, 0), //value = Math.round(self.percent - (remaining * self.percent)), value = self.percent - (remaining * self.percent), cWidth = self.ctx.canvas.width, cHeight = self.ctx.canvas.height, startAngle = 4.72; self.diff = ((value / 100) * Math.PI * 2 *10).toFixed(2); imd = ctx.getImageData(0, 0, cWidth, cHeight); ctx.putImageData(imd, 0, 0); ctx.beginPath(); ctx.clearRect(0, 0, cWidth, cHeight); ctx.lineWidth = 2.1; ctx.strokeStyle = "#fff"; ctx.lineCap = 'butt'; ctx.lineJoin = 'miter'; ctx.beginPath(); if(!self.filldirection){ ctx.arc(cWidth / 2 , cHeight / 2, (cHeight / 2) - 2, self.diff/10+startAngle, startAngle, false); }else{ ctx.arc(cWidth / 2 , cHeight / 2, (cHeight / 2) - 2, startAngle, self.diff/10+startAngle, false); } ctx.stroke(); ctx.closePath(); if (value === self.percent) { cancelAnimationFrame(self.timer); if(typeof self.callback === 'function'){ self.callback(); } } }, enterFrame : function(){ var self = this; if(self.timer){ window.cancelAnimationFrame(self.timer); } self.timer = requestAnimationFrame(function () { self.enterFrame(); }); self.drawCircle(); }, start :function(){ var self = this; var now = new Date().getTime(); self.endTime = now + self.duration; self.enterFrame(); }, stop : function(){ var self = this; cancelAnimationFrame(self.timer); //self.ctx.clearRect(0, 0, self.ctx.canvas.width, self.ctx.canvas.height); } }; global.CirCleProgress = CirCleProgress; }(window)); ;( function(global) { function Parallax(_target, _duration, _percent,_callback, _filldirection, _idx) { }; Parallax.prototype = { parallaxMotion : function( _scroll,_min, _max,_$scope,_callback){ if(_$scope.length==0){return;} var maxscroll = document.body.clientHeight-window.innerHeight; _min=(_min>maxscroll-100?maxscroll-100:_min); var per = (_scroll-_min)/((_max>maxscroll?maxscroll:_max)-_min); per = (per < 0)?0:(per>1)?1:per; if (_callback) { _callback(per); } }, scrollMotion : function(_scroll,_min,_$scope,_callback){ if(_scroll>=_min) { if (_callback && _$scope[0].is_play==undefined ) { _callback(); _$scope[0].is_play=true; } } } }; global.Parallax = Parallax; }(window)); // Main Layer Popup 2018-01-25 $('.layerClose').on('click', function(e){ e.preventDefault(); $(this).parents('.layerPopup').css('display', 'none'); }); /* $(window).resize(function(){ var winPo = $('body').width()/2; var navW = $('.nav_inner').width()/2; var layerW = $('.layerPopup').width(); var layerPo = parseInt(winPo + (navW - layerW)); $('.layerPopup').css('left', layerPo); });*/