$(document).ready(function () { //상단 슬라이더 var g = {} g.startNum = 0; g.timer_bar = null; g.is_pause = false; var $wrap = $('.visual .sliderWrap'); var $items = $wrap.find('.box'); var $txts = $items.find('.txt'); var $imgs = $items.find('.img'); var $prev = $wrap.find('.slick-prev'); var $next = $wrap.find('.slick-next'); var $numLast = $wrap.find('.numLast'); var $bar = $wrap.find('.bar span'); var $play = $wrap.find('.play'); var $pause = $wrap.find('.pause'); var index = 0; var len = $items.length; var interval = 8000; var timer = null; for(var i = 0; i < $items.length; i++){ $(".bar").append("") } $('.bar span').css({"transition":"all 1s ease"}).height(((100/len)*(index+1))+'%'); $numLast.text(function (){ if(len<10){ return '0' + len; }else{ return len; } }); function prev(){ g.startNum = 0; index--; if(index<0){ index=len-1; } init(); } function next(){ g.startNum = 0; index++; if(index>=len){ index=0; } init(); } function init(){ $items.fadeOut(); var $img = $imgs.eq(index); var $txt = $txts.eq(index).find('span'); $txt.each(function (i){ TweenMax.fromTo($(this)[0], 1, {y:40, opacity:0}, {delay:i*0.2/(i+1), y:0, opacity:1, ease:'ease-out'}); }); TweenMax.fromTo($img[0], 1, {y:40, opacity:0}, {y:0, opacity:1, onComplete:function (){ $img.addClass('on'); }}); $items.eq(index).stop().show(); if(index == 0){ $('.bar span').removeClass("on") } setTimeout(function(){ $('.bar span').eq(index).stop().addClass("on") }) slideTimer(interval); clearTimeout(timer); timer = setTimeout(next,interval); } $prev.click(prev); $next.click(next); $pause.click(function (){ g.is_pause = true; clearTimeout(timer); var $gage = $('.gage-bar').eq(g.startNum).nextAll(); //$gage.remove(); $pause.hide(); $play.show(); }); $play.click(function (){ g.is_pause = false; timer = setTimeout(next,(interval/360)*(360-g.startNum)); slideTimer(interval); $play.hide(); $pause.show(); }); init(); //원형 프로그래스바 function slideTimer(dur){ var doms = ''; var $m = $('.visual .progress'); var data = 100; var com = Math.round(data / 100 * 360); var duration = dur/com; var start = g.startNum; $('.visual .gage-bar').remove(); var getVendorPrefix = function() { var body = document.body || document.documentElement, style = body.style, transition = "Transition", vendor = ["Moz", "Webkit", "ms"], lastGage, i = 0; while (i < vendor.length) { if (typeof style[vendor[i] + transition] === "string") { return vendor[i]; } i++; } return false; }; var prefix = getVendorPrefix(); var transform = prefix + 'Transform'; for(var i=0; i <= com; i++){ doms = '
'; $m.append(doms); $('.gage-bar:last').css(transform, 'rotate(' + i + 'deg)'); } $m.find('div').each(function(index, item){ if(g.startNum>index){ $(item).show(); }; g.timer_bar = setTimeout(function (){ if(g.is_pause) return false; g.startNum = index; $(item).stop().fadeIn(50); },(index-start) * duration); }); }; });